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

Method Subscribe

js.go:1503–1508  ·  view source on GitHub ↗

Subscribe creates an async Subscription for JetStream. The stream and consumer names can be provided with the nats.Bind() option. For creating an ephemeral (where the consumer name is picked by the server), you can provide the stream name with nats.BindStream(). If no stream name is specified, the l

(subj string, cb MsgHandler, opts ...SubOpt)

Source from the content-addressed store, hash-verified

1501// consumer with the given name, and if successful, bind to it. If the lookup fails,
1502// then the Subscribe() call will return an error.
1503func (js *js) Subscribe(subj string, cb MsgHandler, opts ...SubOpt) (*Subscription, error) {
1504 if cb == nil {
1505 return nil, ErrBadSubscription
1506 }
1507 return js.subscribe(subj, _EMPTY_, cb, nil, false, false, opts)
1508}
1509
1510// SubscribeSync creates a Subscription that can be used to process messages synchronously.
1511// See important note in Subscribe()

Callers

nothing calls this directly

Calls 1

subscribeMethod · 0.95

Tested by

no test coverage detected