Config#
Junction client configuration.
Classes:
A Backend is a logical target for network traffic. |
|
A Backend is uniquely identifiable by a combination of Service and port. |
|
A fraction, expressed as a numerator and a denominator. |
|
A Route is a policy that describes how a request to a specific virtual host should be routed. |
|
Defines the predicate used to match requests to a given action. |
|
Configure client retry policy. |
|
A RouteRule contains a set of matches that define which requests it applies to, processing rules, and the final destination(s) for matching traffic. |
|
Defines timeouts that can be configured for a HTTP Route. |
|
- class junction.config.Backend[source]#
A Backend is a logical target for network traffic.
A backend configures how all traffic for its
target
is handled. Any traffic routed to this backend will use the configured load balancing policy to spread traffic across available endpoints.Attributes:
- lb: LbPolicyRoundRobin | LbPolicyRingHash | LbPolicyUnspecified#
How traffic to this target should be load balanced.
- class junction.config.BackendId[source]#
A Backend is uniquely identifiable by a combination of Service and port.
[Backend][crate::backend::Backend].
Attributes:
A valid RFC1123 DNS domain name.
The name of the Kubernetes Service to target.
The namespace of the Kubernetes service to target.
The port backend traffic is sent on.
- class junction.config.BackendRef[source]#
Attributes:
A valid RFC1123 DNS domain name.
The name of the Kubernetes Service to target.
The namespace of the Kubernetes service to target.
The port to route traffic to, used in combination with [service][Self::service] to identify the [Backend][crate::backend::Backend] to route traffic to.
The relative weight of this backend relative to any other backends in [the list][RouteRule::backends].
- namespace: str#
The namespace of the Kubernetes service to target. This must be explicitly specified, and won’t be inferred from context.
- junction.config.Duration = str | int | float#
A duration expressed as a total number of seconds. Durations should never be negative.
- class junction.config.HeaderValue[source]#
Attributes:
- name: str#
The name of the HTTP Header. Note header names are case insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2>).
- class junction.config.LbPolicyRingHash[source]#
Attributes:
How to hash an outgoing request into the ring.
The minimum size of the hash ring
- hash_params: List[RequestHashPolicy]#
How to hash an outgoing request into the ring.
Hash parameters are applied in order. If the request is missing an input, it has no effect on the final hash. Hashing stops when only when all polices have been applied or a
terminal
policy matches part of an incoming request.This allows configuring a fallback-style hash, where the value of
HeaderA
gets used, falling back to the value ofHeaderB
.If no policies match, a random hash is generated for each request.
- class junction.config.RequestHashPolicy[source]#
Attributes:
The name of the header to use as hash input.
Whether to stop immediately after hashing this value.
- class junction.config.Route[source]#
A Route is a policy that describes how a request to a specific virtual host should be routed.
Attributes:
The hostnames that match this Route.
A globally unique identifier for this Route.
The ports that match this Route.
The rules that determine whether a request matches and where traffic should be routed.
A list of arbitrary tags that can be added to a Route.
- id: str#
A globally unique identifier for this Route.
Route IDs must be valid RFC 1035 DNS label names - they must start with a lowercase ascii character, and can only contain lowercase ascii alphanumeric characters and the
-
character.
- class junction.config.RouteMatch[source]#
Defines the predicate used to match requests to a given action. Multiple match types are ANDed together; the match will evaluate to true only if all conditions are satisfied. For example, if a match specifies a
path
match and twoquery_params
matches, it will match only if the request’s path matches and both of thequery_params
are matches.The default RouteMatch functions like a path match on the empty prefix, which matches every request.
## Match Ordering
Route matches are [Ordered][Ord] to help break ties. While once a Route is constructed, rules are matched in-order, sorting matches and rules can be useful while constructing a Route in case there isn’t an obvious order matches should apply in. From highest-value to lowest value, routes are ordered by:
“Exact” path match.
“Prefix” path match with largest number of characters.
Method match.
Largest number of header matches.
Largest number of query param matches.
Note that this means a route that matches on a path is greater than a route that only matches on headers. To get a natural sort order by precedence, you may want to reverse-sort a list of matches.
Attributes:
Specifies HTTP request header matchers.
Specifies HTTP method matcher.
Specifies a HTTP request path matcher.
Specifies HTTP query parameter matchers.
- headers: List[HeaderMatchRegularExpression | HeaderMatchExact]#
Specifies HTTP request header matchers. Multiple match values are ANDed together, meaning, a request must match all the specified headers.
- method: str#
Specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method.
- path: PathMatchPrefix | PathMatchRegularExpression | PathMatchExact#
Specifies a HTTP request path matcher.
- query_params: List[QueryParamMatchRegularExpression | QueryParamMatchExact]#
Specifies HTTP query parameter matchers. Multiple match values are ANDed together, meaning, a request must match all the specified query parameters.
- class junction.config.RouteRetry[source]#
Configure client retry policy.
Attributes:
The total number of attempts to make when retrying this request.
The amount of time to back off between requests during a series of retries.
The HTTP error codes that retries should be applied to.
- class junction.config.RouteRule[source]#
A RouteRule contains a set of matches that define which requests it applies to, processing rules, and the final destination(s) for matching traffic.
See the Junction docs for a high level description of how Routes and RouteRules behave.
# Ordering Rules
Route rules may be ordered by comparing their maximum [matches][Self::matches], breaking ties by comparing their next-highest match. This provides a total ordering on rules. Note that having a sorted list of rules does not mean that the list of all matches across all rules is totally sorted.
This ordering is provided for convenience - clients match rules in the order they’re listed in a Route.
Attributes:
Where the traffic should route if this rule matches.
A list of match rules applied to an outgoing request.
A human-readable name for this rule.
How to retry requests.
- backends: List[BackendRef]#
Where the traffic should route if this rule matches.
If no backends are specified, this route becomes a black hole for traffic and all matching requests return an error.
- matches: List[RouteMatch]#
A list of match rules applied to an outgoing request. Each match is independent; this rule will be matched if any of the listed matches is satisfied.
If no matches are specified, this Rule matches any outgoing request.
- name: str#
A human-readable name for this rule.
This name is completely optional, and will only be used in diagnostics to make it easier to debug. Diagnostics that don’t have a name will be referred to by their index in a Route’s list of rules.
- retry: RouteRetry#
How to retry requests. If not specified, requests are not retried.
- class junction.config.RouteTimeouts[source]#
Defines timeouts that can be configured for a HTTP Route.
Attributes:
Specifies a timeout for an individual request to a backend.
Specifies the maximum duration for a HTTP request.
- backend_request: str | int | float#
Specifies a timeout for an individual request to a backend. This covers the time from when the request first starts being sent to when the full response has been received from the backend.
Because the overall request timeout encompasses the backend request timeout, the value of this timeout must be less than or equal to the value of the overall timeout.
- request: str | int | float#
Specifies the maximum duration for a HTTP request. This timeout is intended to cover as close to the whole request-response transaction as possible.
An entire client HTTP transaction may result in more than one call to destination backends, for example, if automatic retries are configured.