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)
| 54 | // * The stopper will run asynchronously because the stop method could take a |
| 55 | // while and we don't want to block |
| 56 | func 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 |