Skip to content

Commit 077e0ef

Browse files
committed
only log if new env. fix poll timeout
1 parent 1b2698d commit 077e0ef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

client.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (c *Client) pollEnvironment(ctx context.Context, pollForever bool) {
344344
log := c.log.With(slog.String("worker", "poll"))
345345
update := func() {
346346
log.Debug("polling environment")
347-
ctx, cancel := context.WithTimeout(ctx, c.config.envRefreshInterval)
347+
ctx, cancel := context.WithTimeout(ctx, c.config.timeout)
348348
defer cancel()
349349
err := c.UpdateEnvironment(ctx)
350350
if err != nil {
@@ -434,14 +434,21 @@ func (c *Client) UpdateEnvironment(ctx context.Context) error {
434434
}
435435
return f
436436
}
437+
isNew := false
438+
previousEnv := c.environment.Load()
439+
if previousEnv == nil || env.UpdatedAt.After(previousEnv.(*environments.EnvironmentModel).UpdatedAt) {
440+
isNew = true
441+
}
437442
c.environment.Store(&env)
438443
identitiesWithOverrides := make(map[string]identities.IdentityModel)
439444
for _, id := range env.IdentityOverrides {
440445
identitiesWithOverrides[id.Identifier] = *id
441446
}
442447
c.identitiesWithOverrides.Store(identitiesWithOverrides)
443448

444-
c.log.Info("environment updated", "environment", env.APIKey)
449+
if isNew {
450+
c.log.Info("environment updated", "environment", env.APIKey, "updated_at", env.UpdatedAt)
451+
}
445452

446453
return nil
447454
}

0 commit comments

Comments
 (0)