pub struct ServiceInstance {
pub id: String,
pub service_name: String,
pub host: String,
pub port: u16,
pub secure: bool,
pub status: InstanceStatus,
pub metadata: HashMap<String, String>,
pub tags: Vec<String>,
pub registered_at: DateTime<Utc>,
pub last_heartbeat: DateTime<Utc>,
pub last_status_change: DateTime<Utc>,
}Expand description
Represents a service instance in the ScoutQuest discovery system.
A service instance contains all the information needed to connect to and identify a specific instance of a service, including its network location, health status, and metadata.
Fields§
§id: StringUnique identifier for this service instance
service_name: StringName of the service this instance belongs to
host: StringHostname or IP address where the service is running
port: u16Port number where the service is listening
secure: boolWhether the service uses HTTPS/TLS
status: InstanceStatusCurrent status of the service instance
metadata: HashMap<String, String>Custom metadata key-value pairs
Tags associated with this service instance
registered_at: DateTime<Utc>Timestamp when the service was first registered
last_heartbeat: DateTime<Utc>Timestamp of the last heartbeat received
last_status_change: DateTime<Utc>Timestamp when the status last changed
Implementations§
Source§impl ServiceInstance
impl ServiceInstance
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Returns true if the service instance is healthy and ready to serve requests.
Sourcepub fn get_url(&self, path: &str) -> String
pub fn get_url(&self, path: &str) -> String
Constructs the full URL for a given path on this service instance.
§Arguments
path- The API path to append to the base URL
§Returns
A complete URL string ready to be used for HTTP requests.
§Examples
use scoutquest_rust::*;
use std::collections::HashMap;
use chrono::Utc;
let instance = ServiceInstance {
id: "test-1".to_string(),
service_name: "api".to_string(),
host: "localhost".to_string(),
port: 3000,
secure: false,
status: InstanceStatus::Up,
metadata: HashMap::new(),
tags: Vec::new(),
registered_at: Utc::now(),
last_heartbeat: Utc::now(),
last_status_change: Utc::now(),
};
assert_eq!(instance.get_url("/users"), "http://localhost:3000/users");
assert_eq!(instance.get_url("users"), "http://localhost:3000/users");Trait Implementations§
Source§impl Clone for ServiceInstance
impl Clone for ServiceInstance
Source§fn clone(&self) -> ServiceInstance
fn clone(&self) -> ServiceInstance
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more