NewSentinelClient returns a Redis Sentinel client. Passing nil Options will cause a panic.
(opt *Options)
| 619 | // NewSentinelClient returns a Redis Sentinel client. |
| 620 | // Passing nil Options will cause a panic. |
| 621 | func NewSentinelClient(opt *Options) *SentinelClient { |
| 622 | if opt == nil { |
| 623 | panic("redis: NewSentinelClient nil options") |
| 624 | } |
| 625 | opt.init() |
| 626 | c := &SentinelClient{ |
| 627 | baseClient: &baseClient{ |
| 628 | opt: opt, |
| 629 | onClose: &onCloseHooks{}, |
| 630 | }, |
| 631 | } |
| 632 | |
| 633 | // Initialize push notification processor using shared helper |
| 634 | // Use void processor for Sentinel clients |
| 635 | c.pushProcessor = NewVoidPushNotificationProcessor() |
| 636 | |
| 637 | c.initHooks(hooks{ |
| 638 | dial: c.baseClient.dial, |
| 639 | process: c.baseClient.process, |
| 640 | }) |
| 641 | |
| 642 | // Generate unique pool names for metrics |
| 643 | uniqueID := generateUniqueID() |
| 644 | mainPoolName := opt.Addr + "_" + uniqueID |
| 645 | pubsubPoolName := opt.Addr + "_" + uniqueID + "_pubsub" |
| 646 | |
| 647 | var err error |
| 648 | c.connPool, err = newConnPool(opt, c.dialHook, mainPoolName) |
| 649 | if err != nil { |
| 650 | panic(fmt.Errorf("redis: failed to create connection pool: %w", err)) |
| 651 | } |
| 652 | c.pubSubPool, err = newPubSubPool(opt, c.dialHook, pubsubPoolName) |
| 653 | if err != nil { |
| 654 | panic(fmt.Errorf("redis: failed to create pubsub pool: %w", err)) |
| 655 | } |
| 656 | |
| 657 | return c |
| 658 | } |
| 659 | |
| 660 | // GetPushNotificationHandler returns the handler for a specific push notification name. |
| 661 | // Returns nil if no handler is registered for the given name. |
no test coverage detected