pub struct ConsulConfig {
pub config: Option<Config>,
pub watch_services: Option<Vec<WatchService>>,
}Fields§
§config: Option<Config>§watch_services: Option<Vec<WatchService>>Implementations§
Source§impl ConsulConfig
impl ConsulConfig
pub async fn load_config(path: &str) -> Result<()>
pub async fn new_request(&self, method: Method, path: &str) -> Result<Request>
Sourcepub async fn service_register(
&self,
service: &AgentServiceRegistration,
) -> Result<StatusCode>
pub async fn service_register( &self, service: &AgentServiceRegistration, ) -> Result<StatusCode>
service_register is used to register a new service with the local agent
use consul_rs::api::CONSUL_CONFIG;
use async_std::task::block_on;
use consul_rs::agent::AgentServiceRegistration;
let clone_consul = CONSUL_CONFIG.clone();
let consul = block_on(clone_consul.read());
let mut service = AgentServiceRegistration::default();
service.ID = Some(String::from("321"));
service.Name = Some(String::from("test"));
service.Port = Some(8080);
service.Address = Some(String::from("127.0.0.1"));
let s = block_on(consul.service_register(&service)).unwrap();
println!("{}", s);pub async fn service_register_opts( &self, service: &AgentServiceRegistration, opts: &ServiceRegisterOpts, ) -> Result<StatusCode>
pub async fn service_register_self( &self, service: &AgentServiceRegistration, opts: &ServiceRegisterOpts, ) -> Result<StatusCode>
Sourcepub async fn service_deregister(&self, service_id: String) -> Result<StatusCode>
pub async fn service_deregister(&self, service_id: String) -> Result<StatusCode>
service_deregister is used to register a new service with the local agent
use consul_rs::api::CONSUL_CONFIG;
use async_std::task::block_on;
use consul_rs::ConsulTrait;
use consul_rs::agent::AgentServiceRegistration;
let clone_consul = CONSUL_CONFIG.clone();
let consul = block_on(clone_consul.read());
let service_id = String::from("321");
let s = block_on(consul.service_deregister(service_id)).unwrap();
println!("{}", s);pub async fn watch_services() -> Result<()>
pub async fn random_policy( &self, service_name: &str, tag: &str, ) -> Result<String>
Trait Implementations§
Source§impl Clone for ConsulConfig
impl Clone for ConsulConfig
Source§fn clone(&self) -> ConsulConfig
fn clone(&self) -> ConsulConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConsulConfig
impl Debug for ConsulConfig
Source§impl Default for ConsulConfig
impl Default for ConsulConfig
Source§impl<'de> Deserialize<'de> for ConsulConfig
impl<'de> Deserialize<'de> for ConsulConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConsulConfig
impl RefUnwindSafe for ConsulConfig
impl Send for ConsulConfig
impl Sync for ConsulConfig
impl Unpin for ConsulConfig
impl UnsafeUnpin for ConsulConfig
impl UnwindSafe for ConsulConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more