MCPcopy
hub / github.com/mudler/LocalAI / Subscribe

Method Subscribe

core/services/messaging/client.go:160–166  ·  view source on GitHub ↗

Subscribe creates a subscription on the given subject. All subscribers receive every message.

(subject string, handler func([]byte))

Source from the content-addressed store, hash-verified

158
159// Subscribe creates a subscription on the given subject. All subscribers receive every message.
160func (c *Client) Subscribe(subject string, handler func([]byte)) (Subscription, error) {
161 return c.confirmSubscription(subject, func(conn *nats.Conn) (*nats.Subscription, error) {
162 return conn.Subscribe(subject, func(msg *nats.Msg) {
163 handler(msg.Data)
164 })
165 })
166}
167
168// QueueSubscribe creates a queue subscription. Within the same queue group,
169// only one subscriber receives each message (load-balanced).

Callers

nothing calls this directly

Calls 3

confirmSubscriptionMethod · 0.95
SubscribeMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected