Skip to content

Commit

Permalink
Backport export reuse-port and reuse-address
Browse files Browse the repository at this point in the history
so that they cabn be configured via config file.

Co-authored-by: Shawn Gerrard <shawn.gerrard@gmail.com>
Signed-off-by: James Blair <mail@jamesblair.net>
  • Loading branch information
jmhbnz and shawngerrard committed Aug 18, 2023
1 parent 2d2e75d commit 2a7bffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/pkg/transport/sockopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ type SocketOpts struct {
// in which case lock on data file could result in unexpected
// condition. User should take caution to protect against lock race.
// [1] https://man7.org/linux/man-pages/man7/socket.7.html
ReusePort bool
ReusePort bool `json:"reuse-port"`
// ReuseAddress enables a socket option SO_REUSEADDR which allows
// binding to an address in `TIME_WAIT` state. Useful to improve MTTR
// in cases where etcd slow to restart due to excessive `TIME_WAIT`.
// [1] https://man7.org/linux/man-pages/man7/socket.7.html
ReuseAddress bool
ReuseAddress bool `json:"reuse-address"`
}

func getControls(sopts *SocketOpts) Controls {
Expand Down
7 changes: 5 additions & 2 deletions server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ type Config struct {
GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"`

// SocketOpts are socket options passed to listener config.
SocketOpts transport.SocketOpts
SocketOpts transport.SocketOpts `json:"socket-options"`

// PreVote is true to enable Raft Pre-Vote.
// If enabled, Raft runs an additional election phase
Expand Down Expand Up @@ -470,7 +470,10 @@ func NewConfig() *Config {
GRPCKeepAliveInterval: DefaultGRPCKeepAliveInterval,
GRPCKeepAliveTimeout: DefaultGRPCKeepAliveTimeout,

SocketOpts: transport.SocketOpts{},
SocketOpts: transport.SocketOpts{
ReusePort: false,
ReuseAddress: false,
},

TickMs: 100,
ElectionMs: 1000,
Expand Down

0 comments on commit 2a7bffc

Please sign in to comment.