add gracefultimeout in server
This commit is contained in:
@@ -86,6 +86,8 @@ type Options struct {
|
||||
DeregisterAttempts int
|
||||
// Hooks may contains SubscriberWrapper, HandlerWrapper or Server func wrapper
|
||||
Hooks options.Hooks
|
||||
// GracefulTimeout timeout for graceful stop server
|
||||
GracefulTimeout time.Duration
|
||||
}
|
||||
|
||||
// NewOptions returns new options struct with default or passed values
|
||||
@@ -108,6 +110,7 @@ func NewOptions(opts ...Option) Options {
|
||||
Version: DefaultVersion,
|
||||
ID: id.Must(),
|
||||
Namespace: DefaultNamespace,
|
||||
GracefulTimeout: DefaultGracefulTimeout,
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
@@ -318,11 +321,22 @@ func Listener(l net.Listener) Option {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
// HandlerOption func
|
||||
type HandlerOption func(*HandlerOptions)
|
||||
|
||||
// HandlerOptions struct
|
||||
type HandlerOptions struct {
|
||||
=======
|
||||
func GracefulTimeout(t time.Duration) options.Option {
|
||||
return func(src interface{}) error {
|
||||
return options.Set(src, t, ".GracefulTimeout")
|
||||
}
|
||||
}
|
||||
|
||||
// HandleOptions struct
|
||||
type HandleOptions struct {
|
||||
>>>>>>> bf0c3016cb09 (add gracefultimeout in server)
|
||||
// Context holds external options
|
||||
Context context.Context
|
||||
// Metadata for handler
|
||||
|
||||
Reference in New Issue
Block a user