Skip to content

Commit

Permalink
Refactor server, proxy and client to adapt to the new API
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Oct 7, 2023
1 parent d094e0c commit 4fc692a
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 169 deletions.
21 changes: 16 additions & 5 deletions network/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,23 @@ func (c *Client) Send(data []byte) (int, *gerr.GatewayDError) {
_, span := otel.Tracer(config.TracerName).Start(c.ctx, "Send")
defer span.End()

sent, err := c.Conn.Write(data)
if err != nil {
c.logger.Error().Err(err).Msg("Couldn't send data to the server")
span.RecordError(err)
return 0, gerr.ErrClientSendFailed.Wrap(err)
sent := 0
received := len(data)
for {
if sent >= received {
break
}

n, err := c.Conn.Write(data)
if err != nil {
c.logger.Error().Err(err).Msg("Couldn't send data to the server")
span.RecordError(err)
return 0, gerr.ErrClientSendFailed.Wrap(err)
}

sent += n
}

c.logger.Debug().Fields(
map[string]interface{}{
"length": sent,
Expand Down
Loading

0 comments on commit 4fc692a

Please sign in to comment.