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

Function ExampleService_Stats

micro/example_test.go:176–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174}
175
176func ExampleService_Stats() {
177 nc, err := nats.Connect("127.0.0.1:4222")
178 if err != nil {
179 log.Fatal(err)
180 }
181 defer nc.Close()
182
183 config := micro.Config{
184 Name: "EchoService",
185 Version: "0.1.0",
186 Endpoint: &micro.EndpointConfig{
187 Subject: "echo",
188 Handler: micro.HandlerFunc(func(r micro.Request) {}),
189 },
190 }
191
192 srv, _ := micro.AddService(nc, config)
193 // stats of a service instance
194 stats := srv.Stats()
195
196 fmt.Println(stats.Endpoints[0].AverageProcessingTime)
197 fmt.Println(stats.Endpoints[0].ProcessingTime)
198
199}
200
201func ExampleService_Stop() {
202 nc, err := nats.Connect("127.0.0.1:4222")

Callers

nothing calls this directly

Calls 5

HandlerFuncFuncType · 0.92
AddServiceFunction · 0.92
ConnectMethod · 0.80
StatsMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected