MCPcopy
hub / github.com/opencloud-eu/opencloud / NewGoMicroHttpServerRunner

Function NewGoMicroHttpServerRunner

pkg/runner/factory.go:56–73  ·  view source on GitHub ↗

NewGoMicroHttpServerRunner creates a new runner based on the provided go-micro's HTTP service. The service is expected to be created via "github.com/opencloud-eu/opencloud/pkg/service/http".NewService(...) function The runner will behave as described: * The task is to start a server and listen for

(name string, server ohttp.Service, opts ...Option)

Source from the content-addressed store, hash-verified

54// * The stopper will run asynchronously because the stop method could take a
55// while and we don't want to block
56func NewGoMicroHttpServerRunner(name string, server ohttp.Service, opts ...Option) *Runner {
57 httpCh := make(chan error, 1)
58 r := New(name, func() error {
59 // start the server and return if it fails
60 if err := server.Server().Start(); err != nil {
61 return err
62 }
63 return <-httpCh // wait for the result
64 }, func() {
65 // stop implies deregistering and waiting for request to finish,
66 // so don't block
67 go func() {
68 httpCh <- server.Server().Stop() // stop and send result through channel
69 close(httpCh)
70 }()
71 }, opts...)
72 return r
73}
74
75// NewGolangHttpServerRunner creates a new runner based on the provided HTTP server.
76// The HTTP server is expected to be created via

Callers 15

ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92
ServerFunction · 0.92

Calls 3

StopMethod · 0.80
NewFunction · 0.70
StartMethod · 0.45

Tested by

no test coverage detected