Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
e17b0460
Unverified
Commit
e17b0460
authored
Nov 07, 2025
by
Graham King
Committed by
GitHub
Nov 08, 2025
Browse files
fix(etcd): KeyValueStore etcd uses our client not the lib directly (#4199)
Signed-off-by:
Graham King
<
grahamk@nvidia.com
>
parent
560bb2fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
lib/runtime/src/storage/key_value_store/etcd.rs
lib/runtime/src/storage/key_value_store/etcd.rs
+31
-30
No files found.
lib/runtime/src/storage/key_value_store/etcd.rs
View file @
e17b0460
...
@@ -7,7 +7,7 @@ use std::time::Duration;
...
@@ -7,7 +7,7 @@ use std::time::Duration;
use
crate
::{
use
crate
::{
storage
::
key_value_store
::{
Key
,
KeyValue
,
WatchEvent
},
storage
::
key_value_store
::{
Key
,
KeyValue
,
WatchEvent
},
transports
::
etcd
::
Client
,
transports
::
etcd
,
};
};
use
async_stream
::
stream
;
use
async_stream
::
stream
;
use
async_trait
::
async_trait
;
use
async_trait
::
async_trait
;
...
@@ -17,11 +17,11 @@ use super::{KeyValueBucket, KeyValueStore, StoreError, StoreOutcome};
...
@@ -17,11 +17,11 @@ use super::{KeyValueBucket, KeyValueStore, StoreError, StoreOutcome};
#[derive(Clone)]
#[derive(Clone)]
pub
struct
EtcdStore
{
pub
struct
EtcdStore
{
client
:
Client
,
client
:
etcd
::
Client
,
}
}
impl
EtcdStore
{
impl
EtcdStore
{
pub
fn
new
(
client
:
Client
)
->
Self
{
pub
fn
new
(
client
:
etcd
::
Client
)
->
Self
{
Self
{
client
}
Self
{
client
}
}
}
}
}
...
@@ -61,7 +61,7 @@ impl KeyValueStore for EtcdStore {
...
@@ -61,7 +61,7 @@ impl KeyValueStore for EtcdStore {
}
}
pub
struct
EtcdBucket
{
pub
struct
EtcdBucket
{
client
:
Client
,
client
:
etcd
::
Client
,
bucket_name
:
String
,
bucket_name
:
String
,
}
}
...
@@ -114,36 +114,37 @@ impl KeyValueBucket for EtcdBucket {
...
@@ -114,36 +114,37 @@ impl KeyValueBucket for EtcdBucket {
)
->
Result
<
Pin
<
Box
<
dyn
futures
::
Stream
<
Item
=
WatchEvent
>
+
Send
+
'life0
>>
,
StoreError
>
{
)
->
Result
<
Pin
<
Box
<
dyn
futures
::
Stream
<
Item
=
WatchEvent
>
+
Send
+
'life0
>>
,
StoreError
>
{
let
prefix
=
make_key
(
&
self
.bucket_name
,
&
""
.into
());
let
prefix
=
make_key
(
&
self
.bucket_name
,
&
""
.into
());
tracing
::
trace!
(
"etcd watch: {prefix}"
);
tracing
::
trace!
(
"etcd watch: {prefix}"
);
let
(
watcher
,
mut
watch_stream
)
=
self
let
watcher
=
self
.client
.client
.etcd_client
()
.kv_watch_prefix
(
&
prefix
)
.clone
()
.watch
(
prefix
.as_bytes
(),
Some
(
WatchOptions
::
new
()
.with_prefix
()))
.await
.await
.map_err
(|
e
|
StoreError
::
EtcdError
(
e
.to_string
()))
?
;
.map_err
(|
e
|
StoreError
::
EtcdError
(
e
.to_string
()))
?
;
let
(
_
,
mut
watch_stream
)
=
watcher
.dissolve
();
let
output
=
stream!
{
let
output
=
stream!
{
let
_
watcher
=
watcher
;
// Keep it alive. Not sure if necessary.
while
let
Some
(
event
)
=
watch_stream
.recv
()
.await
{
while
let
Ok
(
Some
(
resp
))
=
watch_stream
.message
()
.await
{
match
event
{
for
e
in
resp
.events
()
{
etcd
::
WatchEvent
::
Put
(
kv
)
=>
{
let
Some
(
kv
)
=
e
.kv
()
else
{
let
(
k
,
v
)
=
kv
.into_key_value
();
continue
;
let
key
=
match
String
::
from_utf8
(
k
)
{
};
Ok
(
k
)
=>
k
,
let
(
k_bytes
,
v_bytes
)
=
kv
.clone
()
.into_key_value
();
Err
(
err
)
=>
{
let
key
=
match
String
::
from_utf8
(
k_bytes
)
{
tracing
::
error!
(
%
err
,
prefix
,
"Invalid UTF8 in etcd key"
);
Ok
(
k
)
=>
k
,
continue
;
Err
(
err
)
=>
{
}
tracing
::
error!
(
%
err
,
prefix
,
"Invalid UTF8 in etcd key"
);
};
continue
;
let
item
=
KeyValue
::
new
(
key
,
v
.into
());
}
yield
WatchEvent
::
Put
(
item
);
};
}
match
e
.event_type
()
{
etcd
::
WatchEvent
::
Delete
(
kv
)
=>
{
EventType
::
Put
=>
{
let
(
k
,
_
)
=
kv
.into_key_value
();
let
item
=
KeyValue
::
new
(
key
,
v_bytes
.into
());
let
key
=
match
String
::
from_utf8
(
k
)
{
yield
WatchEvent
::
Put
(
item
);
Ok
(
k
)
=>
k
,
}
Err
(
err
)
=>
{
EventType
::
Delete
=>
{
tracing
::
error!
(
%
err
,
prefix
,
"Invalid UTF8 in etcd key"
);
yield
WatchEvent
::
Delete
(
Key
::
from_raw
(
key
));
continue
;
}
}
};
yield
WatchEvent
::
Delete
(
Key
::
from_raw
(
key
));
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment