Skip to content

Commit 893c4d1

Browse files
authored
chore: upgrade momento sdk - consistency, less copypasta (#150)
This change establishes a common pattern for interacting with the service. Rather than copy/pasting matches, MomentoError -> CliError mapping and json dump code around, this names those functionalities as functions: * interact_with_momento: Completes a momento future and maps the result to a Result< HappyCaseType, CliError > * print_whatever_this_is_as_json: prints whatever you feed it as json * drop windows lint, linux lint is enough * also choco install protoc in a windows build near you. Relates to tokio-rs/prost#620 This change was precipitated by the change in the SDK to simplify and coalesce client creation behind the SimpleCacheClientBuilder and triggered by the SDK upgrade. There are small changes to debug and error messages, but this change should cause no functional changes. tired of copypasta. ``` pub async fn delete_cache(cache_name: String, auth_token: String) -> Result<(), CliError> { debug!("deleting cache..."); let mut momento = get_momento_client(auth_token).await?; match momento.delete_cache(&cache_name).await { Ok(_) => (), Err(e) => return Err(CliError { msg: e.to_string() }), }; Ok(()) } ``` becomes ``` pub async fn delete_cache(cache_name: String, auth_token: String) -> Result<(), CliError> { let mut client = get_momento_client(auth_token).await?; interact_with_momento("deleting cache...", client.delete_cache(&cache_name)).await } ```
1 parent c2eec9c commit 893c4d1

File tree

8 files changed

+316
-254
lines changed

8 files changed

+316
-254
lines changed

.github/workflows/cd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ jobs:
130130
needs: release
131131
steps:
132132
- uses: actions/checkout@v2
133+
- name: i guess windows-latest does not have protoc or cmake but we need protoc
134+
run: choco install protoc
133135
- uses: actions-rs/toolchain@v1
134136
with:
135137
toolchain: stable

.github/workflows/ci.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ jobs:
2323
- name: Rigorous lint via Clippy
2424
run: cargo clippy --all-targets --all-features -- -D warnings
2525

26-
rustfmt-windows:
27-
name: Style & Lint - Windows
28-
runs-on: windows-latest
29-
steps:
30-
- uses: actions/checkout@v2
31-
- name: rustfmt
32-
run: cargo fmt -- --check
33-
- name: Rigorous lint via Clippy
34-
run: cargo clippy --all-targets --all-features -- -D warnings
35-
3626
build:
3727
runs-on: ubuntu-latest
3828
steps:
@@ -79,6 +69,8 @@ jobs:
7969
runs-on: windows-latest
8070
steps:
8171
- uses: actions/checkout@v2
72+
- name: i guess windows-latest does not have protoc or cmake but we need protoc
73+
run: choco install protoc
8274
- uses: actions-rs/toolchain@v1
8375
with:
8476
toolchain: stable

0 commit comments

Comments
 (0)