Skip to content

Commit

Permalink
Lower timeout when pushing events to relay.nos.social
Browse files Browse the repository at this point in the history
It is pointless to wait more than a couple of seconds if something is
wrong.
  • Loading branch information
boreq committed Nov 30, 2023
1 parent fca9ddb commit d06acc4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions service/app/handler_process_saved_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var (
)
)

const sendEventToRelayTimeout = 5 * time.Second

type ProcessSavedEvent struct {
id domain.EventId
}
Expand Down Expand Up @@ -165,6 +167,9 @@ func (h *ProcessSavedEventHandler) shouldReplaceContacts(ctx context.Context, ad
}

func (h *ProcessSavedEventHandler) maybeSendEventToRelay(ctx context.Context, event domain.Event) (err error) {
ctx, cancel := context.WithTimeout(ctx, sendEventToRelayTimeout)
defer cancel()

if !ShouldSendEventToRelay(event) {
h.metrics.ReportEventSentToRelay(nosRelayAddress, SendEventToRelayDecisionIgnore, SendEventToRelayResultSuccess)
return nil
Expand Down

0 comments on commit d06acc4

Please sign in to comment.