server: add GracefulTimeout option #304
@ -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
|
||||
|
@ -34,6 +34,8 @@ var (
|
||||
DefaultMaxMsgRecvSize = 1024 * 1024 * 4 // 4Mb
|
||||
// DefaultMaxMsgSendSize holds default max send size
|
||||
DefaultMaxMsgSendSize = 1024 * 1024 * 4 // 4Mb
|
||||
// DefaultGracefulTimeout default time for graceful stop
|
||||
DefaultGracefulTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
// Server is a simple micro server abstraction
|
||||
|
Loading…
x
Reference in New Issue
Block a user