Skip to content

Commit

Permalink
Add Operation Timeouts (#18)
Browse files Browse the repository at this point in the history
* Add option to pass in TCP and UNIX stream socket timeouts

* Update examples to pass in an op_timeout option when connecting

* cargo fmt

* Add optional read, write, and connect timeout to ConnectOpts
  • Loading branch information
nickamorim authored Aug 23, 2023
1 parent 842d643 commit 99858fb
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 1,052 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
16 changes: 4 additions & 12 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ fn main() {
assert_eq!(&value[..], b"Bar");
assert_eq!(flags, 0xdead_beef);

client
.set_noreply(b"key:dontreply", b"1", 0x00_00_00_01, 20)
.unwrap();
client.set_noreply(b"key:dontreply", b"1", 0x00_00_00_01, 20).unwrap();

let (_, cas_val) = client
.increment_cas(b"key:numerical", 10, 1, 20, 0)
.unwrap();
client
.increment_cas(b"key:numerical", 1, 1, 20, cas_val)
.unwrap();
let (_, cas_val) = client.increment_cas(b"key:numerical", 10, 1, 20, 0).unwrap();
client.increment_cas(b"key:numerical", 1, 1, 20, cas_val).unwrap();

let mut handlers = Vec::new();
for _ in 0..4 {
Expand All @@ -38,9 +32,7 @@ fn main() {
let (_, _, mut cas) = client.get_cas(b"key:dontreply").unwrap();
for _ in 0..100 {
debug!("Setting in {:?}", thread::current());
client
.set_cas(b"key:dontreply", b"1", 0x00_10_01, 20, cas)
.unwrap();
client.set_cas(b"key:dontreply", b"1", 0x00_10_01, 20, cas).unwrap();
cas = client.get_cas(b"key:dontreply").unwrap().2;
}
});
Expand Down
3 changes: 1 addition & 2 deletions examples/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use memcached::Client;

fn main() {
let servers = [("tcp://my-sasl-memcached-server.com:11211", 1)];
let mut client =
Client::connect_sasl(&servers, ProtoType::Binary, "my-username", "my-password").unwrap();
let mut client = Client::connect_sasl(&servers, ProtoType::Binary, "my-username", "my-password").unwrap();

client.set(b"Foo", b"Bar", 0xdead_beef, 2).unwrap();
let (value, flags) = client.get(b"Foo").unwrap();
Expand Down
12 changes: 3 additions & 9 deletions examples/unixsocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ fn main() {
assert_eq!(&value[..], b"Bar");
assert_eq!(flags, 0xdead_beef);

client
.set_noreply(b"key:dontreply", b"1", 0x00_00_00_01, 20)
.unwrap();
client.set_noreply(b"key:dontreply", b"1", 0x00_00_00_01, 20).unwrap();

let (_, cas_val) = client
.increment_cas(b"key:numerical", 10, 1, 20, 0)
.unwrap();
client
.increment_cas(b"key:numerical", 1, 1, 20, cas_val)
.unwrap();
let (_, cas_val) = client.increment_cas(b"key:numerical", 10, 1, 20, 0).unwrap();
client.increment_cas(b"key:numerical", 1, 1, 20, cas_val).unwrap();
}
7 changes: 0 additions & 7 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
max_width = 120
fn_call_width = 120
reorder_imports = true
reorder_imports_in_group = true
reorder_imported_names = true
condense_wildcard_suffixes = true
fn_args_layout = "Visual"
fn_call_style = "Visual"
chain_indent = "Visual"
normalize_comments = true
use_try_shorthand = true
Loading

0 comments on commit 99858fb

Please sign in to comment.