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)
| 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. |
| 1639 | func 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 | |
| 1668 | func (c *Conn) Process(ctx context.Context, cmd Cmder) error { |
| 1669 | err := c.processHook(ctx, cmd) |
no test coverage detected