Skip to content

Commit

Permalink
Check if context is canceled during event sent
Browse files Browse the repository at this point in the history
  • Loading branch information
diegobernardes committed Dec 23, 2023
1 parent e8b6980 commit 4ec0dff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,14 @@ func (c *Client) sendRequest(ctx context.Context, req proto.Message) (proto.Mess
}
}

func (c *Client) sendEvent(_ context.Context, e proto.Message) error {
func (c *Client) sendEvent(ctx context.Context, e proto.Message) error {
payload, err := proto.Marshal(e)
if err != nil {
return fmt.Errorf("failed to marshal event: %w", err)
}
if err := ctx.Err(); err != nil {
return fmt.Errorf("context error: %w", err)
}
if errSend := c.transport.send(payload); errSend != nil {
return fmt.Errorf("failed to send the message: %w", errSend)
}
Expand Down

0 comments on commit 4ec0dff

Please sign in to comment.