Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make proto configurable #748

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/server/server_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const (
)

type server struct {
proto string
httpAddress string
grpcAddress string
grpcListenType grpcListenType
Expand Down Expand Up @@ -171,7 +172,7 @@ func (server *server) Start() {
logger.Warnf("Listening for debug on '%s'", server.debugAddress)
var err error
server.listenerMu.Lock()
server.debugListener.listener, err = reuseport.Listen("tcp", server.debugAddress)
server.debugListener.listener, err = reuseport.Listen(server.proto, server.debugAddress)
server.listenerMu.Unlock()

if err != nil {
Expand All @@ -187,7 +188,7 @@ func (server *server) Start() {
server.handleGracefulShutdown()

logger.Warnf("Listening for HTTP on '%s'", server.httpAddress)
list, err := reuseport.Listen("tcp", server.httpAddress)
list, err := reuseport.Listen(server.proto, server.httpAddress)
if err != nil {
logger.Fatalf("Failed to open HTTP listener: '%+v'", err)
}
Expand All @@ -209,7 +210,7 @@ func (server *server) startGrpc() {

switch server.grpcListenType {
case tcp:
lis, err = reuseport.Listen("tcp", server.grpcAddress)
lis, err = reuseport.Listen(server.proto, server.grpcAddress)
case unixDomainSocket:
lis, err = net.Listen("unix", server.grpcAddress)
default:
Expand Down Expand Up @@ -240,7 +241,7 @@ func newServer(s settings.Settings, name string, statsManager stats.Manager, loc
}

ret := new(server)

ret.proto = s.Proto
// setup stats
ret.store = statsManager.GetStatsStore()
ret.scope = ret.store.ScopeWithTags(name, s.ExtraTags)
Expand Down
1 change: 1 addition & 0 deletions src/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

type Settings struct {
Proto string `envconfig:"PROTO" default:"tcp"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about using Protocol instead of Proto? In our context, Proto could be mistaken with ProtoBuf.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe a more straighforward DualStack or EnableIPV6 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this align to reuseport.Listen(proto, addr string) (l net.Listener, err error)

// runtime options
// This value shall be imported into unary server interceptor in order to enable chaining
GrpcUnaryInterceptor grpc.UnaryServerInterceptor
Expand Down
Loading