Skip to content

Commit 3b06b4c

Browse files
committed
Updated examples
Signed-off-by: Zachary Edgell <[email protected]>
1 parent a1843fd commit 3b06b4c

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

examples/distributed-lock/components/statestore.yml

-14
This file was deleted.

examples/distributed-lock/main.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,46 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
88

99
let mut client = dapr::Client::<dapr::client::TonicClient>::connect(addr).await?;
1010

11-
let files = vec![("my-data", b"some-data".to_vec())];
11+
let result = client
12+
.lock(dapr::client::TryLockRequest {
13+
store_name: "lockstore".to_string(),
14+
resource_id: "some-data".to_string(),
15+
lock_owner: "some-random-id".to_string(),
16+
expiry_in_seconds: 60,
17+
})
18+
.await
19+
.unwrap();
1220

13-
client.save_state("statestore", files).await.unwrap();
21+
assert!(result.success);
22+
23+
println!("Successfully locked some-data");
1424

1525
let result = client
1626
.lock(dapr::client::TryLockRequest {
1727
store_name: "lockstore".to_string(),
18-
resource_id: "my-data".to_string(),
28+
resource_id: "some-data".to_string(),
1929
lock_owner: "some-random-id".to_string(),
2030
expiry_in_seconds: 60,
2131
})
2232
.await
2333
.unwrap();
2434

25-
assert!(result.success);
35+
assert!(!result.success);
2636

27-
println!("Successfully locked my-data");
37+
println!("Unsuccessfully locked some-data");
2838

2939
let result = client
3040
.unlock(dapr::client::UnlockRequest {
3141
store_name: "lockstore".to_string(),
32-
resource_id: "my-data".to_string(),
42+
resource_id: "some-data".to_string(),
3343
lock_owner: "some-random-id".to_string(),
3444
})
3545
.await
3646
.unwrap();
3747

3848
assert_eq!(0, result.status);
3949

40-
println!("Successfully unlocked my-data");
50+
println!("Successfully unlocked some-data");
4151

4252
Ok(())
4353
}

0 commit comments

Comments
 (0)