Skip to main content

StubProc

Struct StubProc 

Source
pub struct StubProc<M>
where M: 'static + Send + Sync + Sized + Clone + Debug + Tvf + Default,
{ pub settings: StubSettings, /* private fields */ }
Expand description

Stub processor to respond to a request

use prosa::core::main::{MainProc, MainRunnable};
use prosa::core::proc::{proc, Proc, ProcBusParam, ProcConfig};
use prosa::stub::adaptor::StubParotAdaptor;
use prosa::stub::proc::{StubProc, StubSettings};
use prosa_utils::config::observability::Observability;
use prosa_utils::msg::simple_string_tvf::SimpleStringTvf;
use prosa::core::settings::settings;
use serde::Serialize;

// Main settings
#[settings]
#[derive(Default, Debug, Serialize)]
struct Settings {}

// Create bus and main processor
let settings = Settings::default();
let (bus, main) = MainProc::<SimpleStringTvf>::create(&settings, Some(1));

// Launch a stub processor
let stub_settings = StubSettings::new(vec![String::from("STUB_TEST")]);
let stub_proc = StubProc::<SimpleStringTvf>::create(1, "STUB_PROC".to_string(), bus.clone(), stub_settings);
Proc::<StubParotAdaptor>::run(stub_proc);

// Wait on main task
//main_task.await;

Fields§

§settings: StubSettings

Settings of the processor

Trait Implementations§

Source§

impl<A, M> Proc<A> for StubProc<M>
where A: 'static + Adaptor + StubAdaptor<M> + Send + Sync, M: 'static + Send + Sync + Sized + Clone + Debug + Tvf + Default,

Source§

async fn internal_run(&mut self) -> Result<(), Box<dyn ProcError + Send + Sync>>

Main loop of the processor to implement
Source§

fn get_proc_threads(&self) -> usize

Get the number of processor threads the Processors’s Runtime will use. Must be implemented by the processor if more than one thread is to be used Read more
Source§

fn run(self) -> Result<(), Error>
where Self: Sized + 'static + Send,

Method to run the processor Read more
Source§

impl<M> ProcBusParam for StubProc<M>
where M: 'static + Send + Sync + Sized + Clone + Debug + Tvf + Default,

Source§

fn get_proc_id(&self) -> u32

Getter of the StubProc processor ID

Source§

fn name(&self) -> &str

Getter of the StubProc processor Name

Source§

impl<M> ProcConfig<M> for StubProc<M>
where M: 'static + Send + Sync + Sized + Clone + Debug + Tvf + Default,

Source§

type Settings = StubSettings

Settings use for the ProSA processor
Source§

fn create( proc_id: u32, proc_name: String, main: Main<M>, settings: Self::Settings, ) -> Self

Method to create a processor out of it’s configuration
Source§

fn get_proc_param(&self) -> &ProcParam<M>

Getter of the processor parameters
Source§

fn create_raw(proc_id: u32, proc_name: String, main: Main<M>) -> Self
where Self: Sized, Self::Settings: Default,

Method to create a processor with not specific configuration
Source§

impl<M> ProcEpilogue for StubProc<M>
where M: 'static + Send + Sync + Sized + Clone + Debug + Tvf + Default,

Source§

fn get_proc_restart_delay(&self) -> (Duration, u32)

Getter to know timer for processor restart in case of error
Source§

async fn remove_proc( &self, err: Option<Box<dyn ProcError + Send + Sync>>, ) -> Result<(), BusError>

Method to remove the processor with a signal queue to the main task Read more
Source§

fn is_stopping(&self) -> bool

Indicates whether ProSA is stopping Prevents the rebooting of processors

Auto Trait Implementations§

§

impl<M> Freeze for StubProc<M>

§

impl<M> !RefUnwindSafe for StubProc<M>

§

impl<M> Send for StubProc<M>

§

impl<M> Sync for StubProc<M>

§

impl<M> Unpin for StubProc<M>

§

impl<M> UnsafeUnpin for StubProc<M>

§

impl<M> !UnwindSafe for StubProc<M>

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

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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