-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
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,3 +1,5 @@ | ||
mod retry_policy; | ||
mod telemetry_policy; | ||
|
||
pub use retry_policy::{RetryOptions, RetryPolicy}; | ||
pub use telemetry_policy::{TelemetryOptions, TelemetryPolicy}; |
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::{Context, Policy, PolicyResult, Request, Response}; | ||
|
||
use async_trait::async_trait; | ||
use std::sync::Arc; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct TelemetryOptions { | ||
application_id: Option<String>, | ||
} | ||
|
||
impl TelemetryOptions { | ||
pub fn new(application_id: Option<String>) -> Self { | ||
Self { application_id } | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct TelemetryPolicy { | ||
options: TelemetryOptions, | ||
} | ||
|
||
impl TelemetryPolicy { | ||
pub fn new(options: TelemetryOptions) -> Self { | ||
Self { options } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Policy for TelemetryPolicy { | ||
async fn send( | ||
&self, | ||
ctx: Context, | ||
request: &mut Request, | ||
next: &[Arc<dyn Policy>], | ||
) -> PolicyResult<Response> { | ||
// TODO | ||
next[0].send(ctx.clone(), request, &next[1..]).await | ||
} | ||
} |