Skip to content

Commit

Permalink
Move trace attributes inside null checking block
Browse files Browse the repository at this point in the history
Exit GatewayD if connections cannot be made
Update exit codes
  • Loading branch information
mostafa committed Mar 6, 2023
1 parent 9f2781b commit dce05ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
41 changes: 22 additions & 19 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
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
)

0 comments on commit dce05ce

Please sign in to comment.