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

Method PublishMsg

nats.go:4365–4375  ·  view source on GitHub ↗

PublishMsg publishes the Msg structure, which includes the Subject, an optional Reply and an optional Data field.

(m *Msg)

Source from the content-addressed store, hash-verified

4363// PublishMsg publishes the Msg structure, which includes the
4364// Subject, an optional Reply and an optional Data field.
4365func (nc *Conn) PublishMsg(m *Msg) error {
4366 if m == nil {
4367 return ErrInvalidMsg
4368 }
4369 hdr, err := m.headerBytes()
4370 if err != nil {
4371 return err
4372 }
4373 validateReply := m.Reply != _EMPTY_
4374 return nc.publish(m.Subject, m.Reply, validateReply, hdr, m.Data)
4375}
4376
4377// PublishRequest will perform a Publish() expecting a response on the
4378// reply subject. Use Request() for automatically waiting for a response

Callers 1

TestNilConnectionFunction · 0.95

Calls 2

publishMethod · 0.95
headerBytesMethod · 0.80

Tested by 1

TestNilConnectionFunction · 0.76