1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-08-10 21:52:01 +02:00

Wait() option now accept *sync.WaitGroup

The original signature accept a boolean, and it feel like a little
verbose, since when people pass in this option, he/she always want to
pass a `true`.

Now if input `wg` is nil, it has same effect as passing `true` in
original code. Furthermore, if user want's finer grained control during
shutdown, one can pass in a predefined `wg`, so that server will wait
against it during shutdown.
This commit is contained in:
magodo
2019-05-27 21:17:57 +08:00
parent e035664a8c
commit ebc479ef2c
4 changed files with 32 additions and 15 deletions

View File

@@ -54,7 +54,7 @@ func newFunction(opts ...Option) Function {
service.Server().Init(
// ensure the service waits for requests to finish
server.Wait(true),
server.Wait(nil),
// wrap handlers and subscribers to finish execution
server.WrapHandler(fnHandlerWrapper(fn)),
server.WrapSubscriber(fnSubWrapper(fn)),