Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache analyzer sources #401

Merged
merged 1 commit into from
May 4, 2023
Merged

Conversation

Andrew7234
Copy link
Collaborator

@Andrew7234 Andrew7234 commented May 3, 2023

We currently pass the source config to each analyzer, and then the analyzer instantiates its own source. That's bad for two reasons:

  • Aesthetics/consistency: The target storage is passed into anaylzers pre-initialized
  • Pogreb (our KV store/cache) does not work if multiple instances try to access the same db; parallelism from within the same instance is supported though

Tasks:

todo: choose better var names

target storage.TargetStorage
logger *log.Logger
}

type AllSources struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

AbstractServiceClientFactoryAggregator here we come

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah... I was also considering SourceFactory but it's not quite satisfactory either

@Andrew7234 Andrew7234 marked this pull request as ready for review May 3, 2023 17:34
@Andrew7234 Andrew7234 requested review from aefhm and mitjat as code owners May 3, 2023 17:34
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

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

Thank you!
I have only one important comment, it's about closing resources.

cmd/analyzer/analyzer.go Outdated Show resolved Hide resolved
analyzer/runtime/runtime.go Outdated Show resolved Hide resolved
Comment on lines 245 to 255
sdkPT := cfg.Source.SDKParaTime(common.RuntimeEmerald)
sourceClient, err1 := sources.Runtime(ctx, common.RuntimeEmerald)
if err1 != nil {
return nil, err1
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little unhappy about the code duplication here, but I don't have great suggestions.

Refloating a recent idea: If RuntimeClient used lazy initialization, we could inline sources.Runtime and not worry about errors. It would also make it so the query_on_cache_miss flag is not needed.
Definitely not something we'd do in this PR, and likely ever, just from the effort/benefits ratio. But a man can dream.

cmd/analyzer/analyzer.go Outdated Show resolved Hide resolved
cmd/analyzer/analyzer.go Show resolved Hide resolved
@Andrew7234 Andrew7234 force-pushed the andrew7234/unify-analyzer-source branch from d6a7fd4 to 8bd1aaa Compare May 4, 2023 00:20
tweaking var names

linter

do not close source in analyzers; rename vars; update comments
@Andrew7234 Andrew7234 force-pushed the andrew7234/unify-analyzer-source branch from 8bd1aaa to 4b75ba3 Compare May 4, 2023 16:33
@Andrew7234 Andrew7234 enabled auto-merge May 4, 2023 16:33
@Andrew7234 Andrew7234 merged commit 6b99c7b into main May 4, 2023
@Andrew7234 Andrew7234 deleted the andrew7234/unify-analyzer-source branch May 4, 2023 16:40
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.

3 participants