MCPcopy
hub / github.com/nats-io/nats.go / NewEncodedConn

Function NewEncodedConn

enc.go:69–81  ·  view source on GitHub ↗

NewEncodedConn will wrap an existing Connection and utilize the appropriate registered encoder. Deprecated: Encoded connections are no longer supported.

(c *Conn, encType string)

Source from the content-addressed store, hash-verified

67//
68// Deprecated: Encoded connections are no longer supported.
69func 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//

Callers

nothing calls this directly

Calls 3

EncoderForTypeFunction · 0.85
IsClosedMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected