-
Notifications
You must be signed in to change notification settings - Fork 674
feat: Introduce storage_client in DistributedRuntime #3507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,18 +19,21 @@ use anyhow::Result; | |
| use axum_server::tls_rustls::RustlsConfig; | ||
| use derive_builder::Builder; | ||
| use dynamo_runtime::logging::make_request_span; | ||
| use dynamo_runtime::storage::key_value_store::EtcdStore; | ||
| use dynamo_runtime::storage::key_value_store::KeyValueStore; | ||
| use dynamo_runtime::storage::key_value_store::MemoryStore; | ||
| use dynamo_runtime::transports::etcd; | ||
| use std::net::SocketAddr; | ||
| use tokio::task::JoinHandle; | ||
| use tokio_util::sync::CancellationToken; | ||
| use tower_http::trace::TraceLayer; | ||
|
|
||
| /// HTTP service shared state | ||
| #[derive(Default)] | ||
| pub struct State { | ||
| metrics: Arc<Metrics>, | ||
| manager: Arc<ModelManager>, | ||
| etcd_client: Option<etcd::Client>, | ||
| store: Arc<dyn KeyValueStore>, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already merged but for future PRs: I'm looking at this and I'm thinking, wait, couldn't you set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, I see that you're doing that in 92 (double storing etcd). It would be good to see a comment saying something like |
||
| flags: StateFlags, | ||
| } | ||
|
|
||
|
|
@@ -76,6 +79,7 @@ impl State { | |
| manager, | ||
| metrics: Arc::new(Metrics::default()), | ||
| etcd_client: None, | ||
| store: Arc::new(MemoryStore::new()), | ||
| flags: StateFlags { | ||
| chat_endpoints_enabled: AtomicBool::new(false), | ||
| cmpl_endpoints_enabled: AtomicBool::new(false), | ||
|
|
@@ -85,11 +89,12 @@ impl State { | |
| } | ||
| } | ||
|
|
||
| pub fn new_with_etcd(manager: Arc<ModelManager>, etcd_client: Option<etcd::Client>) -> Self { | ||
| pub fn new_with_etcd(manager: Arc<ModelManager>, etcd_client: etcd::Client) -> Self { | ||
| Self { | ||
| manager, | ||
| metrics: Arc::new(Metrics::default()), | ||
| etcd_client, | ||
| store: Arc::new(EtcdStore::new(etcd_client.clone())), | ||
| etcd_client: Some(etcd_client), | ||
| flags: StateFlags { | ||
| chat_endpoints_enabled: AtomicBool::new(false), | ||
| cmpl_endpoints_enabled: AtomicBool::new(false), | ||
|
|
@@ -115,6 +120,10 @@ impl State { | |
| self.etcd_client.as_ref() | ||
| } | ||
|
|
||
| pub fn store(&self) -> Arc<dyn KeyValueStore> { | ||
| self.store.clone() | ||
| } | ||
|
|
||
| // TODO | ||
| pub fn sse_keep_alive(&self) -> Option<Duration> { | ||
| None | ||
|
|
@@ -294,9 +303,10 @@ impl HttpServiceConfigBuilder { | |
| let config: HttpServiceConfig = self.build_internal()?; | ||
|
|
||
| let model_manager = Arc::new(ModelManager::new()); | ||
| let etcd_client = config.etcd_client; | ||
| let state = Arc::new(State::new_with_etcd(model_manager, etcd_client)); | ||
|
|
||
| let state = match config.etcd_client { | ||
| Some(etcd_client) => Arc::new(State::new_with_etcd(model_manager, etcd_client)), | ||
| None => Arc::new(State::new(model_manager)), | ||
| }; | ||
| state | ||
| .flags | ||
| .set(&EndpointType::Chat, config.enable_chat_endpoints); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ use dynamo_runtime::storage::key_value_store::Key; | |
| use dynamo_runtime::traits::DistributedRuntimeProvider; | ||
| use dynamo_runtime::{ | ||
| component::Endpoint, | ||
| storage::key_value_store::{EtcdStorage, KeyValueStore, KeyValueStoreManager}, | ||
| storage::key_value_store::{EtcdStore, KeyValueStore, KeyValueStoreManager}, | ||
| }; | ||
|
|
||
| use crate::entrypoint::RouterConfig; | ||
|
|
@@ -409,7 +409,7 @@ impl LocalModel { | |
| self.card.move_to_nats(nats_client.clone()).await?; | ||
|
|
||
| // Publish the Model Deployment Card to KV store | ||
| let kvstore: Box<dyn KeyValueStore> = Box::new(EtcdStorage::new(etcd_client.clone())); | ||
| let kvstore: Box<dyn KeyValueStore> = Box::new(EtcdStore::new(etcd_client.clone())); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI is taking over the word |
||
| let card_store = Arc::new(KeyValueStoreManager::new(kvstore)); | ||
| let lease_id = endpoint.drt().primary_lease().map(|l| l.id()).unwrap_or(0); | ||
| let key = Key::from_raw(endpoint.unique_path(lease_id)); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.