Struct Wora

Source
pub struct Wora<AppEv, AppMetric> {
    pub app_name: String,
    pub dirs: Dirs,
    pub initial_working_dir: PathBuf,
    pub host: Host,
    pub sender: Sender<Event<AppEv>>,
    pub receiver: Receiver<Event<AppEv>>,
    pub leadership: Leadership,
    pub o11y: O11yProcessorOptions<AppMetric>,
    /* private fields */
}
Expand description

All workloads will be able to access the WORA API

Fields§

§app_name: String

application name

§dirs: Dirs

common directories for all executors

§initial_working_dir: PathBuf

current directory where the process was invoked (an executor will likely override this)

§host: Host

host info/stats

§sender: Sender<Event<AppEv>>

Event producer

§receiver: Receiver<Event<AppEv>>

Event receiver

§leadership: Leadership

leadership state

§o11y: O11yProcessorOptions<AppMetric>

Implementations§

Source§

impl<AppEv: Send + Sync + 'static, AppMetric: Send + Sync + 'static> Wora<AppEv, AppMetric>

WORA API

Source

pub fn new( dirs: &Dirs, app_name: String, ev_buf_size: usize, o11y: O11yProcessorOptions<AppMetric>, ) -> Result<Wora<AppEv, AppMetric>, WoraSetupError>

Source

pub fn stats_from_start(&self) -> &HostStats

Examples found in repository?
examples/async_daemon.rs (line 85)
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    async fn setup(
        &mut self,
        wora: &Wora<(), ()>,
        exec: impl AsyncExecutor<(), ()>,
        _fs: impl WFS,
        _o11y: Sender<O11yEvent<()>>,
    ) -> Result<Self::Setup, Box<dyn std::error::Error>> {
        debug!("{:?}", wora.stats_from_start());

        let args = DaemonArgs::parse();
        self.args = args;

        debug!("{:?}", exec.disable_core_dumps());

        Ok(())
    }
Source

pub fn dirs(&self) -> &Dirs

Source

pub async fn emit_event(&self, ev: Event<AppEv>)

Source

pub fn host_os_name(&self) -> &str

Source

pub fn host_os_version(&self) -> Option<String>

Source

pub fn host_architecture(&self) -> Option<String>

Source

pub fn host_hostname(&self) -> Option<String>

Source

pub fn host_cpu_count(&self) -> usize

Source

pub fn host_cpu_max(&self) -> usize

Source

pub async fn schedule_event(&self, duration: Duration, ev: Event<AppEv>)

Source

pub async fn schedule_task<F, Fut>( &self, duration: Duration, future: F, ) -> JoinHandle<TaskOp>
where F: Fn(Sender<O11yEvent<AppMetric>>) -> Fut + Send + 'static, Fut: Future<Output = TaskOp> + Send,

Auto Trait Implementations§

§

impl<AppEv, AppMetric> Freeze for Wora<AppEv, AppMetric>

§

impl<AppEv, AppMetric> !RefUnwindSafe for Wora<AppEv, AppMetric>

§

impl<AppEv, AppMetric> Send for Wora<AppEv, AppMetric>
where AppEv: Send, AppMetric: Send,

§

impl<AppEv, AppMetric> Sync for Wora<AppEv, AppMetric>
where AppEv: Send, AppMetric: Send,

§

impl<AppEv, AppMetric> Unpin for Wora<AppEv, AppMetric>

§

impl<AppEv, AppMetric> !UnwindSafe for Wora<AppEv, AppMetric>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<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