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

Function ExampleService_Reset

micro/example_test.go:253–276  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

251}
252
253func ExampleService_Reset() {
254 nc, err := nats.Connect("127.0.0.1:4222")
255 if err != nil {
256 log.Fatal(err)
257 }
258 defer nc.Close()
259
260 config := micro.Config{
261 Name: "EchoService",
262 Version: "0.1.0",
263 }
264
265 srv, _ := micro.AddService(nc, config)
266
267 // reset endpoint stats on this service
268 srv.Reset()
269
270 empty := micro.Stats{
271 ServiceIdentity: srv.Info().ServiceIdentity,
272 }
273 if !reflect.DeepEqual(srv.Stats(), empty) {
274 log.Fatal("Expected endpoint stats to be empty")
275 }
276}
277
278func ExampleContextHandler() {
279 nc, err := nats.Connect("127.0.0.1:4222")

Callers

nothing calls this directly

Calls 6

AddServiceFunction · 0.92
ConnectMethod · 0.80
ResetMethod · 0.65
InfoMethod · 0.65
StatsMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected