Skip to content

lazy loading customs now#910

Merged
i3149 merged 2 commits into
mainfrom
lazy-load-customs
Jun 25, 2026
Merged

lazy loading customs now#910
i3149 merged 2 commits into
mainfrom
lazy-load-customs

Conversation

@i3149

@i3149 i3149 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 24, 2026 22:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional “lazy loading” of Kentik device custom columns so custom-column data can be fetched on-demand (rather than always during initial device listing), and threads context.Context through device lookup calls.

Changes:

  • Track whether a device’s custom columns have been loaded via a new Device.loadedCustoms flag and LoadedCustoms() accessor.
  • Add KT_API_LAZY_LOAD_CUSTOMS configuration and update KentikApi.GetDevice to optionally load custom columns on first access.
  • Update JCHF flow enrichment to call GetDevice with a context.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/kt/device_types.go Tracks whether custom columns were loaded for a Device.
pkg/cat/jchf.go Updates device lookups to pass context.Context.
pkg/api/api.go Adds lazy-load toggle and on-demand custom-column fetching in GetDevice.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/api.go
Comment on lines +251 to +269
if api.lazyLoadCustoms && !dev.LoadedCustoms() {
api.mux.Lock()
defer api.mux.Unlock()
if dev.LoadedCustoms() {
return dev
}
for _, info := range api.config.KentikCreds {
md := metadata.New(map[string]string{
"X-CH-Auth-Email": info.APIEmail,
"X-CH-Auth-API-Token": info.APIToken,
})
ctxo := metadata.NewOutgoingContext(ctx, md)
err := api.loadCustoms(ctxo, dev.IDStr, dev)
if err != nil {
api.Warnf("Cannot load customs for %s %s, %v", dev.IDStr, info.APIEmail, err)
}
break
}
}
@i3149 i3149 merged commit 34a72f9 into main Jun 25, 2026
2 checks passed
@i3149 i3149 deleted the lazy-load-customs branch June 25, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants