Struct consul_rs::agent::Agent [−][src]
Expand description
Agent can be used to query the Agent endpoints
Fields
c: Option<Client>
Implementations
my_self is used to query the agent we are speaking to for information about itself
host is used to retrieve information about the host the agent is running on such as CPU, memory, and disk. Requires a operator:read ACL token.
metrics is used to query the agent we are speaking to for its current internal metric data
reload triggers a configuration reload for the agent we are connected to.
node_name is used to get the node name of the agent
checks returns the locally registered checks
use async_std::task::block_on; use consul_rs::api; use consul_rs::agent; let lock = agent::AGENT.clone(); let agent = block_on(lock.read()); let res = block_on(agent.checks()).unwrap(); println!("{:?}",res);
checks_with_filter returns a subset of the locally registered checks that match the given filter expression
pub async fn checks_with_filter_opts(
&self,
filter: Filter,
opts: Option<QueryOptions>
) -> Result<HashMap<String, AgentCheck>>
pub async fn checks_with_filter_opts(
&self,
filter: Filter,
opts: Option<QueryOptions>
) -> Result<HashMap<String, AgentCheck>>
checks_with_filter_opts returns a subset of the locally registered checks that match the given filter expression and QueryOptions.
services returns the locally registered services
use async_std::task::block_on; use consul_rs; let lock = consul_rs::agent::AGENT.clone(); let agent = block_on(lock.read()); let res = block_on(agent.services()).unwrap(); println!("{:?}", res);
pub async fn services_with_filter(
&self,
filter: Filter
) -> Result<HashMap<String, AgentService>>
pub async fn services_with_filter(
&self,
filter: Filter
) -> Result<HashMap<String, AgentService>>
services_with_filter returns a subset of the locally registered services that match the given filter expression
pub async fn services_with_filter_opts(
&self,
filter: Filter,
opts: Option<QueryOptions>
) -> Result<HashMap<String, AgentService>>
pub async fn services_with_filter_opts(
&self,
filter: Filter,
opts: Option<QueryOptions>
) -> Result<HashMap<String, AgentService>>
services_with_filter_opts returns a subset of the locally registered services that match the given filter expression and QueryOptions.
service_register is used to register a new service with the local agent
use async_std::task::block_on; use consul_rs; let lock = consul_rs::agent::AGENT.clone(); let agent = block_on(lock.read()); let mut service = consul_rs::agent::AgentServiceRegistration::default(); service.ID = Some("10".to_string()); service.Name = Some("test".to_string()); service.Address = Some("tttt".to_string()); service.Port = Some(8080); let mut opts = consul_rs::agent::ServiceRegisterOpts::default(); opts.ReplaceExistingChecks = true; let status_code = block_on(agent.service_register_opts(service, opts)).unwrap(); assert_eq!(surf::StatusCode::Ok, status_code)
pub async fn service_register_opts(
&self,
service: AgentServiceRegistration,
opts: ServiceRegisterOpts
) -> Result<StatusCode>
pub async fn service_register_opts(
&self,
service: AgentServiceRegistration,
opts: ServiceRegisterOpts
) -> Result<StatusCode>
service_register_opts is used to register a new service with the local agent and can be passed additional options.
use async_std::task::block_on; use consul_rs; let lock = consul_rs::agent::AGENT.clone(); let agent = block_on(lock.read()); let mut service = consul_rs::agent::AgentServiceRegistration::default(); service.ID = Some("10".to_string()); service.Name = Some("test".to_string()); service.Address = Some("tttt".to_string()); service.Port = Some(8080); let mut opts = consul_rs::agent::ServiceRegisterOpts::default(); opts.ReplaceExistingChecks = true; let status_code = block_on(agent.service_register_opts(service, opts)).unwrap(); assert_eq!(surf::StatusCode::Ok, status_code)
service_deregister is used to deregister a service with the local agent
use async_std::task::block_on; use consul_rs::api; let lock = consul_rs::agent::AGENT.clone(); let agent = block_on(lock.read()); let status_code = block_on(agent.service_deregister("10".to_string())).unwrap(); assert_eq!(surf::StatusCode::Ok, status_code)
pub async fn service_deregister_opts(
&self,
service_id: String,
opts: QueryOptions
) -> Result<StatusCode>
pub async fn service_deregister_opts(
&self,
service_id: String,
opts: QueryOptions
) -> Result<StatusCode>
service_deregister_opts is used to deregister a service with the local agent with QueryOptions.
use async_std::task::block_on; use consul_rs; block_on(consul_rs::api::Client::set_config_address("http://0.0.0.0:8500")); block_on(consul_rs::agent::Agent::reload_client()); let lock = consul_rs::agent::AGENT.clone(); let agent = block_on(lock.read()); let opts = consul_rs::api::QueryOptions::default(); let status_code = block_on(agent.service_deregister_opts("10".to_string(), opts)).unwrap(); assert_eq!(surf::StatusCode::Ok, status_code)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Agent
impl UnwindSafe for Agent
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more