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

feat: add support for default cache name on client creation #291

Merged
merged 4 commits into from
Apr 4, 2023

Conversation

pgautier404
Copy link
Contributor

@pgautier404 pgautier404 commented Apr 3, 2023

This commit adds a CacheClient constructor that sets a default cache name for the client. If CacheName is omitted from a given request, the default is used. It also adds a simple happy path test for the new client, mostly as a usage example. Will follow with more complete testing once the basic shape of the client is approved.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@cprice404 cprice404 left a comment

Choose a reason for hiding this comment

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

a couple minor questions / nits but otherwise lgtm

@pgautier404 pgautier404 requested a review from cprice404 April 4, 2023 16:33
return commonCacheClient(props)
}

func (c defaultScsClient) getCacheNameForRequest(request hasCacheName) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

When users call this function with NewCacheClient, it returns defaultCache, right? Where are we setting this default cache?

Copy link
Contributor

Choose a reason for hiding this comment

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

And for the Go SDK, this means that a cache is always created with both NewCacheClient and NewCacheClientWithDefaultCache even if users didn't provide a cache name when calling CreateCache?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default cache is set in the NewCacheClientWithDefaultCache constructor, which returns a CacheClient just like the NewCacheClient constructor. If the client was created using NewCacheClient, it will not have a default cache set and the user has to provide a cache name as part of each request. If the client was created with NewCacheClientWithDefaultCache, it will have a default cache and the user can omit the cache name from the requests.

@pgautier404 pgautier404 requested a review from poppoerika April 4, 2023 18:16
Copy link
Contributor

@poppoerika poppoerika left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@pgautier404 pgautier404 merged commit db53bc0 into main Apr 4, 2023
@pgautier404 pgautier404 deleted the default-cache-name branch April 4, 2023 21:35
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.

None yet

4 participants