Skip to content

Commit

Permalink
Merge pull request #189 from gatewayd-io/fix-bug-in-client-config
Browse files Browse the repository at this point in the history
Fix bug in client config
  • Loading branch information
mostafa authored Mar 6, 2023
2 parents 686f5e1 + dce05ce commit e2cd76a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
45 changes: 24 additions & 21 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,28 +323,28 @@ var runCmd = &cobra.Command{
clientConfig := clients[name]
client := network.NewClient(runCtx, &clientConfig, logger)

eventOptions := trace.WithAttributes(
attribute.String("name", name),
attribute.String("network", client.Network),
attribute.String("address", client.Address),
attribute.Int("receiveBufferSize", client.ReceiveBufferSize),
attribute.Int("receiveChunkSize", client.ReceiveChunkSize),
attribute.String("receiveDeadline", client.ReceiveDeadline.String()),
attribute.String("sendDeadline", client.SendDeadline.String()),
attribute.Bool("tcpKeepAlive", client.TCPKeepAlive),
attribute.String("tcpKeepAlivePeriod", client.TCPKeepAlivePeriod.String()),
attribute.String("localAddress", client.Conn.LocalAddr().String()),
attribute.String("remoteAddress", client.Conn.RemoteAddr().String()),
)
if client.ID != "" {
eventOptions = trace.WithAttributes(
attribute.String("id", client.ID),
if client != nil {
eventOptions := trace.WithAttributes(
attribute.String("name", name),
attribute.String("network", client.Network),
attribute.String("address", client.Address),
attribute.Int("receiveBufferSize", client.ReceiveBufferSize),
attribute.Int("receiveChunkSize", client.ReceiveChunkSize),
attribute.String("receiveDeadline", client.ReceiveDeadline.String()),
attribute.String("sendDeadline", client.SendDeadline.String()),
attribute.Bool("tcpKeepAlive", client.TCPKeepAlive),
attribute.String("tcpKeepAlivePeriod", client.TCPKeepAlivePeriod.String()),
attribute.String("localAddress", client.Conn.LocalAddr().String()),
attribute.String("remoteAddress", client.Conn.RemoteAddr().String()),
)
}
if client.ID != "" {
eventOptions = trace.WithAttributes(
attribute.String("id", client.ID),
)
}

span.AddEvent("Create client", eventOptions)
span.AddEvent("Create client", eventOptions)

if client != nil {
clientCfg := map[string]interface{}{
"id": client.ID,
"network": client.Network,
Expand All @@ -367,6 +367,9 @@ var runCmd = &cobra.Command{
logger.Error().Err(err).Msg("Failed to add client to the pool")
span.RecordError(err)
}
} else {
logger.Error().Msg("Failed to create client, please check the configuration")
os.Exit(gerr.FailedToCreateClient)
}
}

Expand Down Expand Up @@ -530,8 +533,8 @@ var runCmd = &cobra.Command{
go api.StartHTTPAPI(&apiOptions)
logger.Info().Fields(
map[string]interface{}{
"grpcNetwork": apiOptions.GRPCNetwork,
"grpcAddress": apiOptions.GRPCAddress,
"network": apiOptions.GRPCNetwork,
"address": apiOptions.GRPCAddress,
},
).Msg("Started the gRPC API")
}
Expand Down
5 changes: 3 additions & 2 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var (
const (
FailedToLoadPluginConfig = 1
FailedToLoadGlobalConfig = 2
FailedToInitializePool = 3
FailedToStartServer = 4
FailedToCreateClient = 3
FailedToInitializePool = 4
FailedToStartServer = 5
)
2 changes: 1 addition & 1 deletion network/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewClient(ctx context.Context, clientConfig *config.Client, logger zerolog.

var client Client

if clientConfig == nil {
if clientConfig == nil || clientConfig == (&config.Client{}) {
return nil
}

Expand Down

0 comments on commit e2cd76a

Please sign in to comment.