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

Function newConn

redis.go:1639–1666  ·  view source on GitHub ↗

newConn is a helper func to create a new Conn instance. the Conn instance is not thread-safe and should not be shared between goroutines. the parentHooks will be cloned, no need to clone before passing it.

(opt *Options, connPool pool.Pooler, parentHooks *hooksMixin)

Source from the content-addressed store, hash-verified

1637// the Conn instance is not thread-safe and should not be shared between goroutines.
1638// the parentHooks will be cloned, no need to clone before passing it.
1639func newConn(opt *Options, connPool pool.Pooler, parentHooks *hooksMixin) *Conn {
1640 c := Conn{
1641 baseClient: baseClient{
1642 opt: opt,
1643 connPool: connPool,
1644 onClose: &onCloseHooks{},
1645 },
1646 }
1647
1648 if parentHooks != nil {
1649 c.hooksMixin = parentHooks.clone()
1650 }
1651
1652 // Initialize push notification processor using shared helper
1653 // Use void processor for RESP2 connections (push notifications not available)
1654 c.pushProcessor = initializePushProcessor(opt)
1655
1656 c.cmdable = c.Process
1657 c.statefulCmdable = c.Process
1658 c.initHooks(hooks{
1659 dial: c.baseClient.dial,
1660 process: c.baseClient.process,
1661 pipeline: c.baseClient.processPipeline,
1662 txPipeline: c.baseClient.processTxPipeline,
1663 })
1664
1665 return &c
1666}
1667
1668func (c *Conn) Process(ctx context.Context, cmd Cmder) error {
1669 err := c.processHook(ctx, cmd)

Callers 3

reAuthConnectionMethod · 0.85
initConnMethod · 0.85
ConnMethod · 0.85

Calls 3

initializePushProcessorFunction · 0.85
initHooksMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected