Skip to content

Commit

Permalink
chore: add relay base endpoint to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Nov 5, 2024
1 parent 1bacc2c commit 207db79
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error

// Main loop to reconnect to the relay
for {
log.Info("Attempting to subscribe to constraints...")
log.Info("Attempting to subscribe to constraints...", "relayBaseEndpoint", relayBaseEndpoint)

if attempts >= maxAttempts {
log.Error(fmt.Sprintf("Failed to subscribe to constraints after %d attempts", maxAttempts))
log.Error(fmt.Sprintf("Failed to subscribe to constraints after %d attempts", maxAttempts), "relayBaseEndpoint", relayBaseEndpoint)
return errors.New("failed to subscribe to constraints")
}

Expand All @@ -303,14 +303,14 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error

resp, err := client.Do(req)
if err != nil {
log.Error(fmt.Sprintf("Failed to connect to SSE server: %v", err))
log.Error(fmt.Sprintf("Failed to connect to SSE server: %v", err), "relayBaseEndpoint", relayBaseEndpoint)
time.Sleep(retryInterval)
attempts++
continue
}

if resp.StatusCode != http.StatusOK {
log.Error(fmt.Sprintf("Error subscribing to constraints via SSE: %s, %v", resp.Status, err))
log.Error(fmt.Sprintf("Error subscribing to constraints via SSE: %s, %v", resp.Status, err), "relayBaseEndpoint", relayBaseEndpoint)
resp.Body.Close() // Close response body to free resources
time.Sleep(retryInterval)
attempts++
Expand Down Expand Up @@ -341,7 +341,7 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error
// If we encounter an EOF or another serious error, break out to reconnect
isEOF := err == io.EOF || strings.Contains(err.Error(), "EOF")
if isEOF {
log.Error("Encountered EOF. Connection to relay lost, attempting to reconnect...")
log.Error("Encountered EOF. Connection to relay lost, attempting to reconnect...", "relayBaseEndpoint", relayBaseEndpoint)
time.Sleep(retryInterval)
break // Break to reconnect by restarting the main `for` loop
}
Expand Down

0 comments on commit 207db79

Please sign in to comment.