Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9ca481

Browse files
committed
Added ReadOnly session attr
1 parentba1b4cf commita9ca481

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎tokio-postgres/src/config.rs‎

Lines changed: 3 additions & 0 deletions
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
returnErr(Error::config_parse(Box::new(InvalidValue(
627630
"target_session_attrs",

‎tokio-postgres/tests/test/parse.rs‎

Lines changed: 8 additions & 0 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp