Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update service api, to be compatible with deno and go #969

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions async-nats/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ pub struct StatsResponse {
/// Right now, there is only one business endpoint, all other are internals.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct EndpointStats {
// Response type.
#[serde(rename = "type")]
pub response_type: String,
/// Service name.
pub name: String,

pub subject: String,
/// Number of requests handled.
#[serde(rename = "num_requests")]
pub requests: usize,
Expand All @@ -99,7 +98,7 @@ pub struct EndpointStats {
/// Last error that occurred.
pub last_error: Option<error::Error>,
/// Custom data added by [Config::stats_handler]
pub data: String,
pub data: Option<String>
}

/// Information about service instance.
Expand Down Expand Up @@ -377,6 +376,7 @@ impl Group {
.entry(subject.clone())
.or_insert(EndpointStats {
name: subject.clone(),
subject: format!("{}.{subject}", self.prefix),
..Default::default()
});
Ok(Endpoint {
Expand Down Expand Up @@ -483,7 +483,7 @@ impl Service {
let mut endpoint_stats_locked = endpoint_stats.lock().unwrap();
for (key, value) in &mut endpoint_stats_locked.endpoints {
let data = stats_callback.0(key.to_string(), value.clone());
value.data = data;
value.data = Some(data);
}
}

Expand Down Expand Up @@ -666,6 +666,7 @@ impl Service {
.entry(subject.clone())
.or_insert(EndpointStats {
name: subject.clone(),
subject: subject.clone(),
..Default::default()
});
self.subjects.lock().unwrap().push(subject.clone());
Expand Down