Merge pull request 'server: add GracefulTimeout option' (#304) from graceful into v3
Reviewed-on: #304
This commit is contained in:
commit
2d5acaca2f
@ -10,15 +10,15 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: setup-go
|
||||
uses: https://gitea.com/actions/setup-go@v3
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: 1.21
|
||||
- name: checkout
|
||||
uses: https://gitea.com/actions/checkout@v3
|
||||
uses: actions/checkout@v3
|
||||
- name: deps
|
||||
run: go get -v -d ./...
|
||||
- name: lint
|
||||
uses: https://github.com/golangci/golangci-lint-action@v3.4.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
version: v1.52
|
||||
version: v1.52
|
||||
|
@ -10,14 +10,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: https://gitea.com/actions/checkout@v3
|
||||
uses: actions/checkout@v3
|
||||
- name: setup-go
|
||||
uses: https://gitea.com/actions/setup-go@v3
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: 1.21
|
||||
- name: deps
|
||||
run: go get -v -t -d ./...
|
||||
- name: test
|
||||
env:
|
||||
INTEGRATION_TESTS: yes
|
||||
run: go test -mod readonly -v ./...
|
||||
run: go test -mod readonly -v ./...
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module go.unistack.org/micro/v3
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
|
@ -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 {
|
||||
@ -321,6 +324,14 @@ func Listener(l net.Listener) Option {
|
||||
// HandlerOption func
|
||||
type HandlerOption func(*HandlerOptions)
|
||||
|
||||
// GracefulTimeout duration
|
||||
func GracefulTimeout(td time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.GracefulTimeout = td
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// HandlerOptions struct
|
||||
type HandlerOptions struct {
|
||||
// Context holds external options
|
||||
|
@ -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