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

Method NewConn

internal/pool/pubsub.go:36–51  ·  view source on GitHub ↗
(ctx context.Context, network string, addr string, channels []string)

Source from the content-addressed store, hash-verified

34}
35
36func (p *PubSubPool) NewConn(ctx context.Context, network string, addr string, channels []string) (*Conn, error) {
37 if p.closed.Load() {
38 return nil, ErrClosed
39 }
40
41 netConn, err := p.netDialer(ctx, network, addr)
42 if err != nil {
43 return nil, err
44 }
45 cn := NewConnWithBufferSize(netConn, p.opt.ReadBufferSize, p.opt.WriteBufferSize)
46 cn.pubsub = true
47 // Set pool name for metrics
48 cn.SetPoolName(p.opt.Name)
49 atomic.AddUint32(&p.stats.Created, 1)
50 return cn, nil
51}
52
53func (p *PubSubPool) TrackConn(cn *Conn) {
54 atomic.AddUint32(&p.stats.Active, 1)

Callers

nothing calls this directly

Calls 3

NewConnWithBufferSizeFunction · 0.85
SetPoolNameMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected