server: add MaxConn and Listener options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
42f4d26fe4
commit
f14efa64f0
@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -57,6 +58,8 @@ type Options struct {
|
||||
|
||||
Wait *sync.WaitGroup
|
||||
|
||||
// Listener may be passed if already created
|
||||
Listener net.Listener
|
||||
// MaxConn limit connections to server
|
||||
MaxConn int
|
||||
// Other options for implementations of the interface
|
||||
@ -272,6 +275,20 @@ func WrapSubscriber(w SubscriberWrapper) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// MaxConn specifies maximum number of max simultaneous connections to server
|
||||
func MaxConn(n int) Option {
|
||||
return func(o *Options) {
|
||||
o.MaxConn = n
|
||||
}
|
||||
}
|
||||
|
||||
// Listener specifies the net.Listener to use instead of the default
|
||||
func Listener(l net.Listener) Option {
|
||||
return func(o *Options) {
|
||||
o.Listener = l
|
||||
}
|
||||
}
|
||||
|
||||
// HandlerOption func
|
||||
type HandlerOption func(*HandlerOptions)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user