Skip to content

Commit

Permalink
Prevent logging error in offline flag check (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpapillon authored Oct 25, 2024
1 parent 772c1b0 commit 1d59569
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions client/schematic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (c *SchematicClient) CheckFlag(ctx context.Context, evalCtx *schematicgo.Ch
}
}()

if c.isOffline {
return c.getFlagDefault(flagKey)
}

// If nil, check flag with empty context
if evalCtx == nil {
evalCtx = &schematicgo.CheckFlagRequestBody{}
Expand All @@ -93,8 +97,7 @@ func (c *SchematicClient) CheckFlag(ctx context.Context, evalCtx *schematicgo.Ch
}
}

resp, err := c.Client.Features.CheckFlag(ctx, flagKey, evalCtx)

resp, err := c.Features.CheckFlag(ctx, flagKey, evalCtx)
if err != nil {
c.errors <- err

Expand Down Expand Up @@ -209,6 +212,10 @@ func (c *SchematicClient) enqueueEvent(
}
}()

if c.isOffline {
return nil
}

now := time.Now().UTC()
eventBody := &schematicgo.CreateEventRequestBody{
EventType: schematicgo.CreateEventRequestBodyEventType(eventType),
Expand Down Expand Up @@ -239,7 +246,7 @@ func (c *SchematicClient) worker() {
}()

buffer := buffer.NewEventBuffer(
c.Client.Events,
c.Events,
c.errors,
c.logger,
c.eventBufferPeriod,
Expand Down

0 comments on commit 1d59569

Please sign in to comment.