Skip to content

Commit a9ca481

Browse files
committed
Added ReadOnly session attr
1 parent ba1b4cf commit a9ca481

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tokio-postgres/src/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub enum TargetSessionAttrs {
3434
Any,
3535
/// The session must allow writes.
3636
ReadWrite,
37+
/// The session allow only reads.
38+
ReadOnly,
3739
}
3840

3941
/// TLS configuration.
@@ -622,6 +624,7 @@ impl Config {
622624
let target_session_attrs = match value {
623625
"any" => TargetSessionAttrs::Any,
624626
"read-write" => TargetSessionAttrs::ReadWrite,
627+
"read-only" => TargetSessionAttrs::ReadOnly,
625628
_ => {
626629
return Err(Error::config_parse(Box::new(InvalidValue(
627630
"target_session_attrs",

tokio-postgres/tests/test/parse.rs

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ fn settings() {
3434
.keepalives_idle(Duration::from_secs(30))
3535
.target_session_attrs(TargetSessionAttrs::ReadWrite),
3636
);
37+
check(
38+
"connect_timeout=3 keepalives=0 keepalives_idle=30 target_session_attrs=read-only",
39+
Config::new()
40+
.connect_timeout(Duration::from_secs(3))
41+
.keepalives(false)
42+
.keepalives_idle(Duration::from_secs(30))
43+
.target_session_attrs(TargetSessionAttrs::ReadOnly),
44+
);
3745
}
3846

3947
#[test]

0 commit comments

Comments
 (0)