apisix_admin_client

Struct UpstreamBuilder

source
pub struct UpstreamBuilder {
    pub id: Option<String>,
    pub retries: Option<i32>,
    pub retry_timeout: Option<i32>,
    pub timeout: Option<ApisixTimeout>,
    pub nodes: Option<Value>,
    pub service_name: Option<String>,
    pub discovery_type: Option<String>,
    pub type_field: Option<UpstreamType>,
    pub name: Option<String>,
    pub desc: Option<String>,
    pub scheme: Option<UpstreamSchema>,
}

Fields§

§id: Option<String>§retries: Option<i32>§retry_timeout: Option<i32>§timeout: Option<ApisixTimeout>§nodes: Option<Value>§service_name: Option<String>§discovery_type: Option<String>§type_field: Option<UpstreamType>§name: Option<String>§desc: Option<String>§scheme: Option<UpstreamSchema>

Implementations§

source§

impl UpstreamBuilder

source

pub fn new() -> Self

source

pub fn id(self, id: String) -> Self

Upstream ID TODO validate id See [generate_identifier]

source

pub fn u_type(self, u_type: UpstreamType) -> Self

Load balancing algorithm to be used, and the default value is roundrobin. See UpstreamType

source

pub fn nodes(self, nodes: Value) -> Self

IP addresses (with optional ports) of the Upstream nodes represented as a hash table or an array. In the hash table, the key is the IP address and the value is the weight of the node for the load balancing algorithm. For hash table case, if the key is IPv6 address with port, then the IPv6 address must be quoted with square brackets. In the array, each item is a hash table with keys host, weight, and the optional port and priority (defaults to 0). Nodes with lower priority are used only when all nodes with a higher priority are tried and are unavailable. Empty nodes are treated as placeholders and clients trying to access this Upstream will receive a 502 response.

Restrictions: can not be used with service_name

Example: 192.168.1.100:80, [::1]:80

source

pub fn service_name(self, service_name: String) -> Self

Service name used for service discovery

Restrictions: can not be used with nodes

source

pub fn discovery_type(self, discovery_type: String) -> Self

The type of service discovery to be used. The default value is eureka. Required when service_name is defined

source

pub fn retries(self, retries: i32) -> Self

Sets the number of retries while passing the request to Upstream using the underlying Nginx mechanism. Set according to the number of available backend nodes by default. Setting this to 0 disables retry.

source

pub fn retry_timeout(self, retry_timeout: i32) -> Self

Timeout to continue with retries. Setting this to 0 disables the retry timeout.

source

pub fn timeout(self, timeout: ApisixTimeout) -> Self

Sets the timeout (in seconds) for connecting to, and sending and receiving messages to and from the Upstream.

Example: {“connect”: 0.5,“send”: 0.5,“read”: 0.5}

source

pub fn name(self, name: String) -> Self

Identifier for the Upstream

source

pub fn desc(self, desc: String) -> Self

Description of usage scenarios

source

pub fn schema(self, scheme: UpstreamSchema) -> Self

The scheme used when communicating with the Upstream. For an L7 proxy, this value can be one of http, https, grpc, grpcs. For an L4 proxy, this value could be one of tcp, udp, tls. Defaults to http.

source

pub fn build(&self) -> Result<UpstreamRequest, ApisixClientError>

Trait Implementations§

source§

impl Clone for UpstreamBuilder

source§

fn clone(&self) -> UpstreamBuilder

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for UpstreamBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for UpstreamBuilder

source§

fn default() -> UpstreamBuilder

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for UpstreamBuilder

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<UpstreamRequest> for UpstreamBuilder

source§

fn from(upstream: UpstreamRequest) -> Self

Converts to this type from the input type.
source§

impl PartialEq for UpstreamBuilder

source§

fn eq(&self, other: &UpstreamBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for UpstreamBuilder

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for UpstreamBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,