NewEncodedConn will wrap an existing Connection and utilize the appropriate registered encoder. Deprecated: Encoded connections are no longer supported.
(c *Conn, encType string)
| 67 | // |
| 68 | // Deprecated: Encoded connections are no longer supported. |
| 69 | func NewEncodedConn(c *Conn, encType string) (*EncodedConn, error) { |
| 70 | if c == nil { |
| 71 | return nil, errors.New("nats: Nil Connection") |
| 72 | } |
| 73 | if c.IsClosed() { |
| 74 | return nil, ErrConnectionClosed |
| 75 | } |
| 76 | ec := &EncodedConn{Conn: c, Enc: EncoderForType(encType)} |
| 77 | if ec.Enc == nil { |
| 78 | return nil, fmt.Errorf("no encoder registered for '%s'", encType) |
| 79 | } |
| 80 | return ec, nil |
| 81 | } |
| 82 | |
| 83 | // RegisterEncoder will register the encType with the given Encoder. Useful for customization. |
| 84 | // |
nothing calls this directly
no test coverage detected