Skip to content
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

chore(deps): remove once_cell #304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ indexmap = { version = "2", features = ["serde"] }
jsonschema = "0.17"
lazy_static = "1"
nkeys = "0.3.0"
once_cell = "1"
# One version back to avoid clashes with 0.10 of otlp
opentelemetry = { version = "0.17", features = ["rt-tokio"] }
# 0.10 to avoid protoc dep
Expand Down
1 change: 0 additions & 1 deletion crates/wadm-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ anyhow = { workspace = true }
async-nats = { workspace = true }
bytes = { workspace = true }
nkeys = { workspace = true }
once_cell = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
Expand Down
24 changes: 16 additions & 8 deletions crates/wadm-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! A client for interacting with Wadm.
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::{Arc, OnceLock};

use async_nats::HeaderMap;

pub use error::Result;
use error::{ClientError, SerializationError};
pub use loader::ManifestLoader;
use once_cell::sync::Lazy;
use topics::TopicGenerator;
use wadm_types::{
api::{
Expand All @@ -25,11 +24,16 @@ pub mod error;
pub mod loader;
pub mod topics;

static CONTENT_TYPE_HEADERS: Lazy<HeaderMap> = Lazy::new(|| {
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json");
headers
});
/// Headers for `Content-Type: application/json`
static HEADERS_CONTENT_TYPE_JSON: OnceLock<HeaderMap> = OnceLock::new();
/// Retrieve static content type headers
fn get_headers_content_type_json() -> &'static HeaderMap {
HEADERS_CONTENT_TYPE_JSON.get_or_init(|| {
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json");
headers
})
}

#[derive(Clone)]
pub struct Client {
Expand Down Expand Up @@ -103,7 +107,11 @@ impl Client {
let topic = self.topics.model_put_topic();
let resp = self
.client
.request_with_headers(topic, CONTENT_TYPE_HEADERS.clone(), manifest_bytes.into())
.request_with_headers(
topic,
get_headers_content_type_json().clone(),
manifest_bytes.into(),
)
.await?;
let body: PutModelResponse =
serde_json::from_slice(&resp.payload).map_err(SerializationError::from)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/wadm/src/scaler/spreadscaler/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ impl<S: ReadStore + Send + Sync + Clone> Scaler for ProviderSpreadScaler<S> {
let (running, other): (HashMap<&String, &Host>, HashMap<&String, &Host>) =
eligible_hosts.into_iter().partition(|(_host_id, host)| {
host.providers
.get(&ProviderInfo {
.contains(&ProviderInfo {
provider_id: provider_id.to_string(),
provider_ref: provider_ref.to_string(),
annotations: BTreeMap::default(),
}).is_some()
})
});
// Get the count of all running providers
let current_running = running.len();
Expand Down
18 changes: 11 additions & 7 deletions crates/wadm/src/storage/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ impl Default for ProviderStatus {
}
}

impl ToString for ProviderStatus {
fn to_string(&self) -> String {
match self {
Self::Pending => "pending".to_string(),
Self::Running => "running".to_string(),
Self::Failed => "failed".to_string(),
}
impl std::fmt::Display for ProviderStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Pending => "pending".to_string(),
Self::Running => "running".to_string(),
Self::Failed => "failed".to_string(),
}
)
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ pub fn configure_tracing(
}
}

fn get_log_layer<S: for<'a> tracing_subscriber::registry::LookupSpan<'a>>(
structured_logging: bool,
) -> Box<dyn Layer<S> + Send + Sync + 'static>
fn get_log_layer<S>(structured_logging: bool) -> Box<dyn Layer<S> + Send + Sync + 'static>
where
S: for<'a> tracing_subscriber::registry::LookupSpan<'a>,
S: tracing::Subscriber,
{
let log_layer = tracing_subscriber::fmt::layer()
Expand Down
Loading