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

chore: update readme and examples for default credential provider and new topics callbacks #1429

Merged
merged 4 commits into from
Aug 30, 2024

Conversation

anitarua
Copy link
Contributor

@anitarua anitarua commented Aug 28, 2024

Closes https://github.com/momentohq/dev-eco-issue-tracker/issues/975

  • Updates the basic cache, topics, and storage client examples to minimize code now that a default CredentialProvider is used.
  • Updates the main repo README to include info about the default CredentialProvider and best practice
  • Adds example for adding optional onDiscontinuity and onHeartbeat topics callbacks

@anitarua anitarua requested a review from a team August 28, 2024 23:52

async function main() {
const cacheClient = await CacheClient.create({
configuration: Configurations.Laptop.v1(),
credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'),
Copy link
Contributor

Choose a reason for hiding this comment

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

configuration is actually optional now too; I just never went and updated the docs. (so thank you for being diligent about it!)

I think we should leave plenty of examples of how to explicitly set these so that people will know, but in the examples where we omit them, we should omit both. I think this file is a good place to omit both, and whatever shows up in the main README is another good spot. Maybe also in the most basic example file for each product. But probably the rest of the places (e.g. the dictionary example) I'd leave the explicit versions in.

You can use your judgment on which files to update vs leave explicit, but let's go ahead and remove the explicit configuration option from any of the ones where you remove credentialProvider.

configuration: StorageConfigurations.Laptop.latest(),
credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'),
});
const storageClient = new PreviewStorageClient({});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should the props object itself become optional then?
removing the {} results in an Expected 1 arguments, but got 0 error.

Copy link
Contributor

Choose a reason for hiding this comment

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

good call, we could do that later, but I don't think it's a blocker for now.

@anitarua anitarua requested a review from cprice404 August 29, 2024 18:57
@anitarua anitarua merged commit 8f9a09e into main Aug 30, 2024
13 checks passed
@anitarua anitarua deleted the update-examples branch August 30, 2024 20:25
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