-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from connorsmith256/feat/expose-lattice-prefix
Feat/expose lattice prefix
- Loading branch information
Showing
2 changed files
with
90 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,105 @@ | ||
const DEFAULT_TOPIC_PREFIX: &str = "wasmbus.ctl"; | ||
const EVT_TOPIC_PREFIX: &str = "wasmbus.evt"; | ||
|
||
fn prefix(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
fn prefix(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!( | ||
"{}.{}", | ||
topic_prefix | ||
.as_ref() | ||
.unwrap_or(&DEFAULT_TOPIC_PREFIX.to_string()), | ||
ns_prefix | ||
lattice_prefix | ||
) | ||
} | ||
|
||
pub fn control_event(ns_prefix: &str) -> String { | ||
format!("{}.{}", EVT_TOPIC_PREFIX, ns_prefix) | ||
pub fn control_event(lattice_prefix: &str) -> String { | ||
format!("{}.{}", EVT_TOPIC_PREFIX, lattice_prefix) | ||
} | ||
|
||
pub fn provider_auction_subject(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.auction.provider", prefix(topic_prefix, ns_prefix)) | ||
pub fn provider_auction_subject(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.auction.provider", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn actor_auction_subject(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.auction.actor", prefix(topic_prefix, ns_prefix)) | ||
pub fn actor_auction_subject(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.auction.actor", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn advertise_link(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.linkdefs.put", prefix(topic_prefix, ns_prefix)) | ||
pub fn advertise_link(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.linkdefs.put", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn remove_link(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.linkdefs.del", prefix(topic_prefix, ns_prefix)) | ||
pub fn remove_link(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.linkdefs.del", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn publish_registries(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.registries.put", prefix(topic_prefix, ns_prefix)) | ||
pub fn publish_registries(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.registries.put", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub mod commands { | ||
use super::prefix; | ||
|
||
/// Actor commands require a host target | ||
pub fn start_actor(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.la", prefix(topic_prefix, ns_prefix), host) // la - launch actor | ||
pub fn start_actor(topic_prefix: &Option<String>, lattice_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.la", prefix(topic_prefix, lattice_prefix), host) // la - launch actor | ||
} | ||
|
||
pub fn scale_actor(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.scale", prefix(topic_prefix, ns_prefix), host) | ||
pub fn scale_actor(topic_prefix: &Option<String>, lattice_prefix: &str, host: &str) -> String { | ||
format!( | ||
"{}.cmd.{}.scale", | ||
prefix(topic_prefix, lattice_prefix), | ||
host | ||
) | ||
} | ||
|
||
pub fn stop_actor(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.sa", prefix(topic_prefix, ns_prefix), host) // sa - stop actor | ||
pub fn stop_actor(topic_prefix: &Option<String>, lattice_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.sa", prefix(topic_prefix, lattice_prefix), host) // sa - stop actor | ||
} | ||
|
||
pub fn start_provider(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.lp", prefix(topic_prefix, ns_prefix), host) | ||
pub fn start_provider( | ||
topic_prefix: &Option<String>, | ||
lattice_prefix: &str, | ||
host: &str, | ||
) -> String { | ||
format!("{}.cmd.{}.lp", prefix(topic_prefix, lattice_prefix), host) | ||
} | ||
|
||
pub fn stop_provider(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.sp", prefix(topic_prefix, ns_prefix), host) | ||
pub fn stop_provider( | ||
topic_prefix: &Option<String>, | ||
lattice_prefix: &str, | ||
host: &str, | ||
) -> String { | ||
format!("{}.cmd.{}.sp", prefix(topic_prefix, lattice_prefix), host) | ||
} | ||
|
||
pub fn update_actor(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.upd", prefix(topic_prefix, ns_prefix), host) | ||
pub fn update_actor(topic_prefix: &Option<String>, lattice_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.upd", prefix(topic_prefix, lattice_prefix), host) | ||
} | ||
|
||
pub fn stop_host(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.stop", prefix(topic_prefix, ns_prefix), host) | ||
pub fn stop_host(topic_prefix: &Option<String>, lattice_prefix: &str, host: &str) -> String { | ||
format!("{}.cmd.{}.stop", prefix(topic_prefix, lattice_prefix), host) | ||
} | ||
} | ||
|
||
pub mod queries { | ||
use super::prefix; | ||
|
||
pub fn link_definitions(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.get.links", prefix(topic_prefix, ns_prefix)) | ||
pub fn link_definitions(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.get.links", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn claims(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.get.claims", prefix(topic_prefix, ns_prefix)) | ||
pub fn claims(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.get.claims", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
|
||
pub fn host_inventory(topic_prefix: &Option<String>, ns_prefix: &str, host: &str) -> String { | ||
format!("{}.get.{}.inv", prefix(topic_prefix, ns_prefix), host) | ||
pub fn host_inventory( | ||
topic_prefix: &Option<String>, | ||
lattice_prefix: &str, | ||
host: &str, | ||
) -> String { | ||
format!("{}.get.{}.inv", prefix(topic_prefix, lattice_prefix), host) | ||
} | ||
|
||
pub fn hosts(topic_prefix: &Option<String>, ns_prefix: &str) -> String { | ||
format!("{}.ping.hosts", prefix(topic_prefix, ns_prefix)) | ||
pub fn hosts(topic_prefix: &Option<String>, lattice_prefix: &str) -> String { | ||
format!("{}.ping.hosts", prefix(topic_prefix, lattice_prefix)) | ||
} | ||
} |
Oops, something went wrong.