statsig_rust/specs_adapter/
mod.rs1use serde::Serialize;
2pub use specs_adapter_trait::*;
3
4use crate::log_w;
5pub use statsig_bootstrap_specs_adapter::StatsigBootstrapSpecsAdapter;
6pub use statsig_customized_specs_adapter::StatsigCustomizedSpecsAdapter;
7#[cfg(feature = "with_grpc")]
8pub use statsig_grpc_specs_adapter::StatsigGrpcSpecsAdapter;
9pub use statsig_http_specs_adapter::StatsigHttpSpecsAdapter;
10pub use statsig_local_file_specs_adapter::StatsigLocalFileSpecsAdapter;
11
12mod statsig_bootstrap_specs_adapter;
13mod statsig_customized_specs_adapter;
14mod statsig_data_store_specs_adapter;
15#[cfg(feature = "with_grpc")]
16mod statsig_grpc_specs_adapter;
17mod statsig_http_specs_adapter;
18mod statsig_local_file_specs_adapter;
19
20mod specs_adapter_trait;
21
22pub const DEFAULT_INIT_TIMEOUT_MS: u64 = 3000;
23
24const TAG: &str = "SpecAdapterConfig";
25
26#[derive(Debug, Clone, Serialize)]
27pub struct SpecAdapterConfig {
28 pub adapter_type: SpecsAdapterType,
29 pub init_timeout_ms: u64,
30
31 pub specs_url: Option<String>,
32}
33
34#[derive(Debug, Clone, Serialize)]
35pub enum SpecsAdapterType {
36 NetworkGrpcWebsocket,
37 NetworkHttp,
38 DataStore,
39}
40
41impl From<String> for SpecsAdapterType {
42 fn from(val: String) -> Self {
43 match val.to_lowercase().as_str() {
44 "network_grpc_websocket" => SpecsAdapterType::NetworkGrpcWebsocket,
45 "network_http" => SpecsAdapterType::NetworkHttp,
46 "data_store" => SpecsAdapterType::DataStore,
47 _ => {
48 log_w!(
49 TAG,
50 "Invalid specs adapter type: {}. Defaulting to NetworkHttp",
51 val
52 );
53 SpecsAdapterType::NetworkHttp
54 }
55 }
56 }
57}