Skip to main content

Root

Struct Root 

Source
pub struct Root {
    pub plugin_config: Option<Arc<V2PluginConfiguration>>,
    pub open_id_resolvers: Vec<OpenIdResolver>,
    pub open_id_providers: Vec<OpenIdProvider>,
    pub waiting: Mutex<Vec<u32>>,
    pub discovery_active: bool,
}
Expand description

This is the main context which loads and parses the plugin configuration, handles the discovery of all Open ID Providers and creates the HTTP Contexts.

Fields§

§plugin_config: Option<Arc<V2PluginConfiguration>>

Plugin config loaded from the envoy configuration

§open_id_resolvers: Vec<OpenIdResolver>

A set of Open ID Resolvers which are used to load the configuration from the discovery endpoint

§open_id_providers: Vec<OpenIdProvider>

A set of Open ID Providers which are used to store the configuration from the discovery endpoint

§waiting: Mutex<Vec<u32>>

Queue of waiting requests which are waiting for the configuration to be loaded

§discovery_active: bool

Flag to determine if the discovery is active

Trait Implementations§

Source§

impl Context for Root

The context processes all responses from the open id config endpoints and jwks endpoints.

Source§

fn on_http_call_response( &mut self, token_id: u32, _num_headers: usize, _body_size: usize, _num_trailers: usize, )

Called when the response from any http call (sent from root context) is received.

Source§

fn get_current_time(&self) -> SystemTime

Source§

fn get_property(&self, path: Vec<&str>) -> Option<Vec<u8>>

Source§

fn set_property(&self, path: Vec<&str>, value: Option<&[u8]>)

Source§

fn get_shared_data(&self, key: &str) -> (Option<Vec<u8>>, Option<u32>)

Source§

fn set_shared_data( &self, key: &str, value: Option<&[u8]>, cas: Option<u32>, ) -> Result<(), Status>

Source§

fn remove_shared_data(&self, key: &str, cas: Option<u32>) -> Result<(), Status>

Source§

fn register_shared_queue(&self, name: &str) -> u32

Source§

fn resolve_shared_queue(&self, vm_id: &str, name: &str) -> Option<u32>

Source§

fn dequeue_shared_queue(&self, queue_id: u32) -> Result<Option<Vec<u8>>, Status>

Source§

fn enqueue_shared_queue( &self, queue_id: u32, value: Option<&[u8]>, ) -> Result<(), Status>

Source§

fn dispatch_http_call( &self, upstream: &str, headers: Vec<(&str, &str)>, body: Option<&[u8]>, trailers: Vec<(&str, &str)>, timeout: Duration, ) -> Result<u32, Status>

Source§

fn get_http_call_response_headers(&self) -> Vec<(String, String)>

Source§

fn get_http_call_response_headers_bytes(&self) -> Vec<(String, Vec<u8>)>

Source§

fn get_http_call_response_header(&self, name: &str) -> Option<String>

Source§

fn get_http_call_response_header_bytes(&self, name: &str) -> Option<Vec<u8>>

Source§

fn get_http_call_response_body( &self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

Source§

fn get_http_call_response_trailers(&self) -> Vec<(String, String)>

Source§

fn get_http_call_response_trailers_bytes(&self) -> Vec<(String, Vec<u8>)>

Source§

fn get_http_call_response_trailer(&self, name: &str) -> Option<String>

Source§

fn get_http_call_response_trailer_bytes(&self, name: &str) -> Option<Vec<u8>>

Source§

fn dispatch_grpc_call( &self, upstream_name: &str, service_name: &str, method_name: &str, initial_metadata: Vec<(&str, &[u8])>, message: Option<&[u8]>, timeout: Duration, ) -> Result<u32, Status>

Source§

fn on_grpc_call_response( &mut self, _token_id: u32, _status_code: u32, _response_size: usize, )

Source§

fn get_grpc_call_response_body( &self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

Source§

fn cancel_grpc_call(&self, token_id: u32)

Source§

fn open_grpc_stream( &self, cluster_name: &str, service_name: &str, method_name: &str, initial_metadata: Vec<(&str, &[u8])>, ) -> Result<u32, Status>

Source§

fn on_grpc_stream_initial_metadata( &mut self, _token_id: u32, _num_elements: u32, )

Source§

fn get_grpc_stream_initial_metadata(&self) -> Vec<(String, Vec<u8>)>

Source§

fn get_grpc_stream_initial_metadata_value(&self, name: &str) -> Option<Vec<u8>>

Source§

fn send_grpc_stream_message( &self, token_id: u32, message: Option<&[u8]>, end_stream: bool, )

Source§

fn on_grpc_stream_message(&mut self, _token_id: u32, _message_size: usize)

Source§

fn get_grpc_stream_message( &mut self, start: usize, max_size: usize, ) -> Option<Vec<u8>>

Source§

fn on_grpc_stream_trailing_metadata( &mut self, _token_id: u32, _num_elements: u32, )

Source§

fn get_grpc_stream_trailing_metadata(&self) -> Vec<(String, Vec<u8>)>

Source§

fn get_grpc_stream_trailing_metadata_value(&self, name: &str) -> Option<Vec<u8>>

Source§

fn cancel_grpc_stream(&self, token_id: u32)

Source§

fn close_grpc_stream(&self, token_id: u32)

Source§

fn on_grpc_stream_close(&mut self, _token_id: u32, _status_code: u32)

Source§

fn get_grpc_status(&self) -> (u32, Option<String>)

Source§

fn on_foreign_function(&mut self, _function_id: u32, _arguments_size: usize)

Source§

fn call_foreign_function( &self, function_name: &str, arguments: Option<&[u8]>, ) -> Result<Option<Vec<u8>>, Status>

Source§

fn on_done(&mut self) -> bool

Source§

fn done(&self)

Source§

impl RootContext for Root

The root context creates new HTTP Contexts and is responsible for loading the plugin configuration, as well as the discovery of the Open ID Providers. The first step after startup is the loading of the plugin configuration. This is done in the on_configure function. The plugin configuration is loaded from the plugin configuration and parsed into the PluginConfiguration struct. The configuration is then evaluated and checked if the values are valid. If the configuration is valid, the plugin configuration is stored in the root context and the next state is set. The next state is to load the configuration from the Open ID Providers. This is done by creating a new OpenIdResolver for each Open ID Provider in the plugin configuration. The state of the resolver is set to LoadingConfig and the configuration is loaded from the Open ID Configuration endpoint. The response is handled in the on_http_call_response function. If the response is successful, the state is set to LoadingJwks and the jwks endpoint is called. The response is handled in the on_http_call_response function. If the response is successful, the state is set to Ready and the Open ID Provider is stored in the root context. If all Open ID Providers are in the Ready state, the plugin is ready and the waiting requests are resumed.

Source§

fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool

Called when proxy is being configured. This is where the plugin configuration is loaded and the next state is set.

Source§

fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>>

Creates the http context with the information from the open_id_providers and the plugin_configuration. This is called whenever a new http context is created by the proxy. When the plugin is not yet ready, the http context is created in PauseRequests state and the context id is added to the waiting queue to be processed later.

Source§

fn on_tick(&mut self)

The root context is ticking every the configured interval (x) as long as the configuration is not loaded yet.

On every tick, the plugin is checking if the discovery is active. If the discovery is not active, the plugin is starting the discovery (as it has been waiting for reload_interval_in_h * 3600). The discovery is started by setting the discovery active to true and setting the state of all resolvers to LoadingConfig. The ticking period is set to x ms to not overload the openid configuration endpoint (x is the configured interval).

If the discovery is active, the plugin is checking if all resolvers are in Ready state. If all resolvers are in Ready state, the plugin is resuming all requests that were sent during the loading phase. The discovery is switched to false and the ticking period is set to the configured interval.

If the discovery is active and not all resolvers are in Ready state, the plugin is making a call to the openid configuration endpoint or the jwks endpoint depending on the state of the resolver.

Source§

fn get_type(&self) -> Option<ContextType>

This is one of those functions that need to be there for some reason but we are not sure why. It just doesn’t work without it.

Source§

fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool

Source§

fn get_vm_configuration(&self) -> Option<Vec<u8>>

Source§

fn get_plugin_configuration(&self) -> Option<Vec<u8>>

Source§

fn set_tick_period(&self, period: Duration)

Source§

fn on_queue_ready(&mut self, _queue_id: u32)

Source§

fn on_log(&mut self)

Source§

fn create_stream_context( &self, _context_id: u32, ) -> Option<Box<dyn StreamContext>>

Auto Trait Implementations§

§

impl !Freeze for Root

§

impl RefUnwindSafe for Root

§

impl Send for Root

§

impl Sync for Root

§

impl Unpin for Root

§

impl UnsafeUnpin for Root

§

impl UnwindSafe for Root

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,