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

Function runPublisher

examples/nats-bench/main.go:152–171  ·  view source on GitHub ↗
(nc *nats.Conn, startwg, donewg *sync.WaitGroup, numMsgs int, msgSize int)

Source from the content-addressed store, hash-verified

150}
151
152func runPublisher(nc *nats.Conn, startwg, donewg *sync.WaitGroup, numMsgs int, msgSize int) {
153 startwg.Done()
154
155 args := flag.Args()
156 subj := args[0]
157 var msg []byte
158 if msgSize > 0 {
159 msg = make([]byte, msgSize)
160 }
161
162 start := time.Now()
163
164 for i := 0; i < numMsgs; i++ {
165 nc.Publish(subj, msg)
166 }
167 nc.Flush()
168 benchmark.AddPubSample(bench.NewSample(numMsgs, msgSize, start, time.Now(), nc))
169
170 donewg.Done()
171}
172
173func runSubscriber(nc *nats.Conn, startwg, donewg *sync.WaitGroup, numMsgs int, msgSize int) {
174 args := flag.Args()

Callers 1

mainFunction · 0.85

Calls 5

NewSampleFunction · 0.92
AddPubSampleMethod · 0.80
DoneMethod · 0.65
PublishMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected