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

Method Publish

core/services/messaging/client.go:149–157  ·  view source on GitHub ↗

Publish marshals data as JSON and publishes it to the given subject.

(subject string, data any)

Source from the content-addressed store, hash-verified

147
148// Publish marshals data as JSON and publishes it to the given subject.
149func (c *Client) Publish(subject string, data any) error {
150 payload, err := json.Marshal(data)
151 if err != nil {
152 return fmt.Errorf("marshalling message for %s: %w", subject, err)
153 }
154 c.mu.RLock()
155 defer c.mu.RUnlock()
156 return c.conn.Publish(subject, payload)
157}
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) {

Callers

nothing calls this directly

Calls 1

PublishMethod · 0.65

Tested by

no test coverage detected