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

Function ExampleService_Stopped

micro/example_test.go:228–251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226}
227
228func ExampleService_Stopped() {
229 nc, err := nats.Connect("127.0.0.1:4222")
230 if err != nil {
231 log.Fatal(err)
232 }
233 defer nc.Close()
234
235 config := micro.Config{
236 Name: "EchoService",
237 Version: "0.1.0",
238 }
239
240 srv, _ := micro.AddService(nc, config)
241
242 // stop a service
243 err = srv.Stop()
244 if err != nil {
245 log.Fatal(err)
246 }
247
248 if srv.Stopped() {
249 fmt.Println("service stopped")
250 }
251}
252
253func ExampleService_Reset() {
254 nc, err := nats.Connect("127.0.0.1:4222")

Callers

nothing calls this directly

Calls 5

AddServiceFunction · 0.92
ConnectMethod · 0.80
StopMethod · 0.65
StoppedMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected