consul_rs/config_entry.rs
1use lazy_static::lazy_static;
2use serde_derive::{Deserialize, Serialize};
3pub type ProxyMode = String;
4
5lazy_static!(
6 /// ProxyModeDefault represents no specific mode and should
7 /// be used to indicate that a different layer of the configuration
8 /// chain should take precedence
9 pub static ref PROXY_MODE_DEFAULT: ProxyMode = {
10 String::new()
11 };
12
13 /// ProxyModeTransparent represents that inbound and outbound application
14 /// traffic is being captured and redirected through the proxy.
15 pub static ref PROXY_MODE_TRANSPARENT: ProxyMode = {
16 String::from("transparent")
17 };
18
19 /// ProxyModeDirect represents that the proxy's listeners must be dialed directly
20 /// by the local application and other proxies.
21 pub static ref PROXY_MODE_DIRECT: ProxyMode = {
22 String::from("direct")
23 };
24);
25
26pub type MeshGatewayMode = String;
27
28lazy_static!(
29 /// MeshGatewayModeDefault represents no specific mode and should
30 /// be used to indicate that a different layer of the configuration
31 /// chain should take precedence
32 pub static ref MESH_GATEWAY_MODE_DEFAULT: MeshGatewayMode = {
33 String::new()
34 };
35
36 /// MeshGatewayModeNone represents that the Upstream Connect connections
37 /// should be direct and not flow through a mesh gateway.
38 pub static ref MESH_GATEWAY_MODE_NONE: MeshGatewayMode = {
39 String::from("none")
40 };
41
42 /// MeshGatewayModeLocal represents that the Upstream Connect connections
43 /// should be made to a mesh gateway in the local datacenter.
44 pub static ref MESH_GATEWAY_MODE_LOCAL: MeshGatewayMode = {
45 String::from("local")
46 };
47
48 /// MeshGatewayModeRemote represents that the Upstream Connect connections
49 /// should be made to a mesh gateway in a remote datacenter.
50 pub static ref MESH_GATEWAY_MODE_REMOTE: MeshGatewayMode = {
51 String::from("remote")
52 };
53);
54
55/// MeshGatewayConfig controls how Mesh Gateways are used for upstream Connect services
56#[derive(Default, Debug, Clone, Serialize, Deserialize)]
57#[allow(non_snake_case)]
58pub struct MeshGatewayConfig {
59 // Mode is the mode that should be used for the upstream connection.
60 pub Mode: Option<MeshGatewayMode>,
61}
62
63/// ExposeConfig describes HTTP paths to expose through Envoy outside of Connect.
64/// Users can expose individual paths and/or all HTTP/GRPC paths for checks.
65#[derive(Default, Debug, Clone, Serialize, Deserialize)]
66#[allow(non_snake_case)]
67pub struct ExposeConfig {
68 /// Checks defines whether paths associated with Consul checks will be exposed.
69 /// This flag triggers exposing all HTTP and GRPC check paths registered for the service.
70 pub Checks: Option<bool>,
71
72 /// Paths is the list of paths exposed through the proxy.
73 pub Paths: Option<Vec<ExposePath>>,
74}
75
76#[derive(Default, Debug, Clone, Serialize, Deserialize)]
77#[allow(non_snake_case)]
78pub struct ExposePath {
79 /// ListenerPort defines the port of the proxy's listener for exposed paths.
80 pub ListenerPort: Option<usize>,
81
82 /// Path is the path to expose through the proxy, ie. "/metrics."
83 pub Path: Option<String>,
84
85 /// LocalPathPort is the port that the service is listening on for the given path.
86 pub LocalPathPort: Option<usize>,
87
88 /// Protocol describes the upstream's service protocol.
89 /// Valid values are "http" and "http2", defaults to "http"
90 pub Protocol: Option<String>,
91
92 /// ParsedFromCheck is set if this path was parsed from a registered check
93 pub ParsedFromCheck: Option<bool>,
94}