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: add snippets for dev docs, corrected some docstring examples in cache client #253

Merged
merged 4 commits into from
May 6, 2024

Conversation

anitarua
Copy link
Contributor

@anitarua anitarua commented May 3, 2024

Addresses #210

Comment on lines 11 to 12
#momento = "0.15.0"
momento = { path = "../" }
Copy link
Contributor Author

@anitarua anitarua May 3, 2024

Choose a reason for hiding this comment

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

examples are currently using the local SDK, but once we cut a release we can update this here and probably find a way to verify examples in CI

Copy link
Contributor

@malandis malandis left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. As a discussion point, I see two things:

  1. In the examples should we use the ?-operator to propagate errors up from the client calls?
  2. Should we test for particular error cases in some examples?

To illustrate, in some snippets we use the ?-operator on the cache calls, then display the answer in the happy case.

On others we match on the result and display an error.

On others we test for particular error codes, eg:

    match cache_client.set(cache_name, "key", "value").await {
        Ok(_) => println!("Set successful"),
        Err(e) => {
            if let MomentoErrorCode::NotFoundError = e.error_code {
                println!("Cache not found: {}", cache_name);
            } else {
                eprintln!("Error setting value in cache {}: {}", cache_name, e);
            }
        }
    }

My inclination given Rust's features is to:

  1. Bubble up the errors using ?
  2. Match on all the other cases (hit vs miss, stored vs not stored, cache created vs already exists)

We can socialize the options with the team during the bug bash.

Copy link
Contributor

@malandis malandis left a comment

Choose a reason for hiding this comment

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

Couple small issues. Looks great otherwise and much improved and cleaner.

example/src/bin/docs_examples.rs Outdated Show resolved Hide resolved
example/src/bin/docs_examples.rs Outdated Show resolved Hide resolved
@anitarua anitarua merged commit 834a1c5 into main May 6, 2024
6 checks passed
@anitarua anitarua deleted the dev-docs-snippets branch May 6, 2024 17:48
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