MCPcopy
hub / github.com/redis/go-redis / newConnPool

Function newConnPool

options.go:728–776  ·  view source on GitHub ↗
(
	opt *Options,
	dialer func(ctx context.Context, network, addr string) (net.Conn, error),
	poolName string,
)

Source from the content-addressed store, hash-verified

726}
727
728func newConnPool(
729 opt *Options,
730 dialer func(ctx context.Context, network, addr string) (net.Conn, error),
731 poolName string,
732) (*pool.ConnPool, error) {
733 poolSize, err := util.SafeIntToInt32(opt.PoolSize, "PoolSize")
734 if err != nil {
735 return nil, err
736 }
737
738 minIdleConns, err := util.SafeIntToInt32(opt.MinIdleConns, "MinIdleConns")
739 if err != nil {
740 return nil, err
741 }
742
743 maxIdleConns, err := util.SafeIntToInt32(opt.MaxIdleConns, "MaxIdleConns")
744 if err != nil {
745 return nil, err
746 }
747
748 maxActiveConns, err := util.SafeIntToInt32(opt.MaxActiveConns, "MaxActiveConns")
749 if err != nil {
750 return nil, err
751 }
752
753 return pool.NewConnPool(&pool.Options{
754 Dialer: func(ctx context.Context) (net.Conn, error) {
755 return dialer(ctx, opt.Network, opt.Addr)
756 },
757 PoolFIFO: opt.PoolFIFO,
758 PoolSize: poolSize,
759 MaxConcurrentDials: opt.MaxConcurrentDials,
760 PoolTimeout: opt.PoolTimeout,
761 DialTimeout: opt.DialTimeout,
762 DialerRetries: opt.DialerRetries,
763 DialerRetryTimeout: opt.DialerRetryTimeout,
764 DialerRetryBackoff: opt.DialerRetryBackoff,
765 MinIdleConns: minIdleConns,
766 MaxIdleConns: maxIdleConns,
767 MaxActiveConns: maxActiveConns,
768 ConnMaxIdleTime: opt.ConnMaxIdleTime,
769 ConnMaxLifetime: opt.ConnMaxLifetime,
770 ConnMaxLifetimeJitter: opt.ConnMaxLifetimeJitter,
771 ReadBufferSize: opt.ReadBufferSize,
772 WriteBufferSize: opt.WriteBufferSize,
773 PushNotificationsEnabled: opt.Protocol == 3,
774 Name: poolName,
775 }), nil
776}
777
778func newPubSubPool(
779 opt *Options,

Callers 4

NewClientFunction · 0.85
NewFailoverClientFunction · 0.85
NewSentinelClientFunction · 0.85
pool_test.goFile · 0.85

Calls 2

SafeIntToInt32Function · 0.92
NewConnPoolFunction · 0.92

Tested by

no test coverage detected