Skip to content
Merged
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
2 changes: 1 addition & 1 deletion grpcx/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grpcx

type Config struct {
type ServerConfig struct {
Address string `confx:"address" usage:"gRPC server address" validate:"required"`
RegisterReflection bool `confx:"registerReflection" usage:"register the server reflection service"`
}
6 changes: 3 additions & 3 deletions grpcx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (

type Listener net.Listener

func SetupListener(lc *lifecycle.Lifecycle, conf *Config) (Listener, error) {
func SetupListener(lc *lifecycle.Lifecycle, conf *ServerConfig) (Listener, error) {
return netx.SetupListenerFactory("grpc-listener", conf.Address)(lc)
}

func SetupServerFactory(name string, opts ...grpc.ServerOption) func(ctx context.Context, lc *lifecycle.Lifecycle, listener Listener, conf *Config) (*grpc.Server, error) {
return func(ctx context.Context, lc *lifecycle.Lifecycle, listener Listener, conf *Config) (*grpc.Server, error) {
func SetupServerFactory(name string, opts ...grpc.ServerOption) func(ctx context.Context, lc *lifecycle.Lifecycle, listener Listener, conf *ServerConfig) (*grpc.Server, error) {
return func(ctx context.Context, lc *lifecycle.Lifecycle, listener Listener, conf *ServerConfig) (*grpc.Server, error) {
grpcServer := grpc.NewServer(opts...)

if conf.RegisterReflection {
Expand Down
2 changes: 1 addition & 1 deletion httpx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"
)

type Config struct {
type ServerConfig struct {
Address string `confx:"address" usage:"HTTP server address" validate:"required"`
ReadTimeout time.Duration `confx:"readTimeout" usage:"maximum duration before timing out read of the request"`
ReadHeaderTimeout time.Duration `confx:"readHeaderTimeout" usage:"maximum duration before timing out read of the request headers" validate:"ltefield=ReadTimeout"`
Expand Down
8 changes: 4 additions & 4 deletions httpx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (

type Listener net.Listener

func SetupListener(lc *lifecycle.Lifecycle, conf *Config) (Listener, error) {
func SetupListener(lc *lifecycle.Lifecycle, conf *ServerConfig) (Listener, error) {
return netx.SetupListenerFactory("http-listener", conf.Address)(lc)
}

func SetupServerFactory(name string, handler http.Handler) func(ctx context.Context, lc *lifecycle.Lifecycle, conf *Config, listener Listener) (*http.Server, error) {
return func(ctx context.Context, lc *lifecycle.Lifecycle, conf *Config, listener Listener) (*http.Server, error) {
func SetupServerFactory(name string, handler http.Handler) func(ctx context.Context, lc *lifecycle.Lifecycle, conf *ServerConfig, listener Listener) (*http.Server, error) {
return func(ctx context.Context, lc *lifecycle.Lifecycle, conf *ServerConfig, listener Listener) (*http.Server, error) {
srv, err := NewServer(conf, handler)
if err != nil {
return nil, err
Expand Down Expand Up @@ -58,7 +58,7 @@ func SetupServerFactory(name string, handler http.Handler) func(ctx context.Cont
}
}

func NewServer(conf *Config, handler http.Handler) (*http.Server, error) {
func NewServer(conf *ServerConfig, handler http.Handler) (*http.Server, error) {
srv := &http.Server{
ReadTimeout: conf.ReadTimeout,
ReadHeaderTimeout: conf.ReadHeaderTimeout,
Expand Down