Skip to content

Commit

Permalink
twip
Browse files Browse the repository at this point in the history
  • Loading branch information
cataphract committed Sep 23, 2024
1 parent 78c29c2 commit 40182a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion remote-config/src/fetch/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait FileStorage {
}

/// Fundamental configuration of the RC client, which always must be set.
#[derive(Clone, Hash, Eq, PartialEq)]
#[derive(Clone, Hash, Eq, PartialEq, Debug)]
pub struct ConfigInvariants {
pub language: String,
pub tracer_version: String,
Expand Down
17 changes: 14 additions & 3 deletions sidecar/src/shm_remote_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,29 @@ use zwohash::ZwoHasher;
pub struct RemoteConfigWriter(OneWayShmWriter<NamedShmHandle>);
pub struct RemoteConfigReader(OneWayShmReader<NamedShmHandle, CString>);

#[no_mangle]
extern "C" fn debug_dump_inv_tar(id: *const ConfigInvariants, target: *const Arc<Target>) {
let id = unsafe { &*id };
let target = unsafe { &*target };
debug!("ConfigInvariants: {:#?}", id);
debug!("Target: {:#?}", target);
}

fn path_for_remote_config(id: &ConfigInvariants, target: &Arc<Target>) -> CString {
// We need a stable hash so that the outcome is independent of the process
let mut hasher = ZwoHasher::default();
id.hash(&mut hasher);
target.hash(&mut hasher);
// datadog remote config, on macos we're restricted to 31 chars
CString::new(format!(
let res = CString::new(format!(
"/ddrc{}-{}",
primary_sidecar_identifier(),
hasher.finish()
))
.unwrap()
.unwrap();
debug_dump_inv_tar(id, target);
debug!("Path for remote config: {:?}", res.to_str().unwrap());
res
}

#[no_mangle]
Expand Down Expand Up @@ -373,7 +384,7 @@ fn read_config(path: &str) -> anyhow::Result<(RemoteConfigValue, u32)> {
/// It is guaranteed that no two configurations sharing the same RemoteConfigPath are applied at
/// once. They will always be Remove()d first, then Add()ed again upon update.
pub struct RemoteConfigManager {
invariants: ConfigInvariants,
pub invariants: ConfigInvariants,
active_target: Option<Arc<Target>>,
pub active_reader: Option<RemoteConfigReader>,
encountered_targets: HashMap<Arc<Target>, (RemoteConfigReader, Vec<String>)>,
Expand Down

0 comments on commit 40182a3

Please sign in to comment.