-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zahari Dichev <[email protected]>
- Loading branch information
1 parent
130050d
commit 4144b19
Showing
17 changed files
with
708 additions
and
332 deletions.
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
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,67 @@ | ||
use super::{ | ||
FailureAccrual, GrpcRetryCondition, GrpcRoute, HttpRetryCondition, HttpRoute, RouteRetry, | ||
RouteSet, RouteTimeouts, TcpRoute, TlsRoute, TrafficPolicy, | ||
}; | ||
|
||
use std::{net::SocketAddr, num::NonZeroU16}; | ||
|
||
/// OutboundPolicyKind describes a resolved outbound policy that is | ||
/// either attributed to a resource or is a fallback one. | ||
#[allow(clippy::large_enum_variant)] | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum OutboundPolicyKind { | ||
Fallback(SocketAddr), | ||
Resource(ResourceOutboundPolicy), | ||
} | ||
|
||
/// ResourceOutboundPolicy expresses the known resource types | ||
/// that can be parents for outbound policy. They each come with | ||
/// specific metadata that is used when putting together the final | ||
/// policy response. | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum ResourceOutboundPolicy { | ||
Service { | ||
authority: String, | ||
policy: OutboundPolicy, | ||
}, | ||
Egress { | ||
traffic_policy: TrafficPolicy, | ||
original_dst: SocketAddr, | ||
policy: OutboundPolicy, | ||
}, | ||
} | ||
|
||
// ParentMeta carries information resource-specific | ||
// information about the parent to which outbound policy | ||
// is associated. | ||
#[derive(Clone, Debug, Hash, PartialEq, Eq)] | ||
pub enum ParentMeta { | ||
Service { authority: String }, | ||
EgressNetwork(TrafficPolicy), | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct OutboundPolicy { | ||
pub parent_meta: ParentMeta, | ||
pub http_routes: RouteSet<HttpRoute>, | ||
pub grpc_routes: RouteSet<GrpcRoute>, | ||
pub tls_routes: RouteSet<TlsRoute>, | ||
pub tcp_routes: RouteSet<TcpRoute>, | ||
pub name: String, | ||
pub namespace: String, | ||
pub port: NonZeroU16, | ||
pub opaque: bool, | ||
pub accrual: Option<FailureAccrual>, | ||
pub http_retry: Option<RouteRetry<HttpRetryCondition>>, | ||
pub grpc_retry: Option<RouteRetry<GrpcRetryCondition>>, | ||
pub timeouts: RouteTimeouts, | ||
} | ||
|
||
impl ResourceOutboundPolicy { | ||
pub fn policy(&self) -> &OutboundPolicy { | ||
match self { | ||
Self::Egress { policy, .. } => policy, | ||
Self::Service { policy, .. } => policy, | ||
} | ||
} | ||
} |
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,26 @@ | ||
use std::{net::SocketAddr, num::NonZeroU16}; | ||
|
||
/// OutboundDiscoverTarget allows us to express the fact that | ||
/// a policy resolution can be fulfilled by either a resource | ||
/// we know about (a specific EgressNetwork or a Service) or | ||
/// by our fallback mechanism. | ||
#[derive(Clone, Debug)] | ||
pub enum OutboundDiscoverTarget { | ||
Resource(ResourceTarget), | ||
Fallback(SocketAddr), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct ResourceTarget { | ||
pub name: String, | ||
pub namespace: String, | ||
pub port: NonZeroU16, | ||
pub source_namespace: String, | ||
pub kind: Kind, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | ||
pub enum Kind { | ||
EgressNetwork(SocketAddr), | ||
Service, | ||
} |
Oops, something went wrong.