Skip to content

chore: refactor entry into deployment and runtime #14575

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

Merged
merged 8 commits into from
Sep 5, 2024

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Sep 5, 2024

  • RuntimeEntry has no startup value, and omits functions required to be serpent compatible.
  • DeploymentEntry has no New() function because it is always instantiated from a serpent context. There is no point to implementing a New() function that will never be used in prod.
  • Now there exists a Manager that will be instantiated once for the app. The Manager produces Resolvers such that we can implement some shared cache.
  • Resolvers do not know about namespaces. Only managers (the factory) does now.

RuntimeEntry has no startup value, and omits functions required
to be serpent compatible.
@Emyrk Emyrk requested a review from dannykopping September 5, 2024 17:24
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

}

func NewMemoryCachedResolver(cache *syncmap.Map[string, cacheEntry], wrapped Resolver) *MemoryCachedResolver {
return &MemoryCachedResolver{
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: panic here if cache is nil

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should actually delete the cache resolver before we merge to main. Was just testing out some api usage with it.

// Validate that it returns that value.
require.Equal(t, base.String(), field.String())
// Validate that there is no org-level override right now.
_, err := field.Resolve(ctx, mgr.DeploymentResolver(db))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: DeploymentResolver feels like the wrong name; let's keep it for now but it's worth revisiting, I feel.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

// resolver from the manager.
// TODO: Delete MemoryCacheManager and implement it properly in 'StoreManager'.
type MemoryCacheManager struct {
cache *syncmap.Map[string, cacheEntry]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! TIL about syncmap

Copy link
Member Author

Choose a reason for hiding this comment

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

Handy little guy

Co-authored-by: Danny Kopping <danny@coder.com>
@Emyrk Emyrk marked this pull request as ready for review September 5, 2024 21:12
@Emyrk Emyrk merged commit 23ef17e into dk/runtime-configs Sep 5, 2024
27 checks passed
@Emyrk Emyrk deleted the stevenmasley/runtime_refactor branch September 5, 2024 21:12
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants