[][src]Struct actyxos_sdk::event_service::EventService

pub struct EventService { /* fields omitted */ }

An Event Service API client with which you can perform queries and publish events.

This feature is only available under the client feature flag.

The common way to create an EventService instance is to use the default constructor:

use actyxos_sdk::event_service::EventService;

let event_service: EventService = EventService::default();

This will connect to the local Event Service, either an ActyxOS node in development mode or the production ActyxOS node where the app is deployed (in particular, it will inspect the AX_EVENT_SERVICE_URI environment variable and fall back to http://localhost:4454/api/).

Implementations

impl EventService[src]

pub fn new(client: &Client, url: Url) -> Self[src]

Construct a new client from a reqwest Client and a base URL. The URL must end with a slash as the endpoints below it are resolved as relative paths.

pub async fn get_offsets<'_>(&'_ self) -> Result<OffsetMap, EventServiceError>[src]

Obtain an OffsetMap that describes the set of all events currently known to the Event Service. New events are continuously ingested from other ActyxOS nodes, which means that calling this method again at a later time is likely to produce a larger OffsetMap.

pub async fn node_id<'_>(&'_ self) -> Result<SourceId, EventServiceError>[src]

Obtain the local ActyxOS node ID to use it as a source ID in Subscription::local.

pub async fn query_upto<'_>(
    &'_ self,
    upper_bound: OffsetMap,
    subscriptions: Vec<Subscription>,
    order: Order
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
[src]

Request a stream of events from the beginning of time until the given upper bound that must be less than or equal to the currently returned result of get_offsets (using that result here is quite common).

The order of events is specified independently, i.e. if you ask for LamportReverse order you’ll get the events starting with upper_bound and going backwards down to the beginning of time.

The delivered event stream will be filtered by the subscriptions: an event is included if any of the subscriptions matches.

pub async fn query_between<'_>(
    &'_ self,
    lower_bound: OffsetMap,
    upper_bound: OffsetMap,
    subscriptions: Vec<Subscription>,
    order: Order
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
[src]

Request a stream of events from the given lower bound until the given upper bound that must be less than or equal to the currently returned result of get_offsets (using that result here is quite common).

The order of events is specified independently, i.e. if you ask for LamportReverse order you’ll get the events starting with upper_bound and going backwards down to the lower bound.

The delivered event stream will be filtered by the subscriptions: an event is included if any of the subscriptions matches.

pub async fn subscribe<'_>(
    &'_ self,
    subscriptions: Vec<Subscription>
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
[src]

Subscribe to an unbounded stream of events starting at the beginning of time and continuing past the currently known events (see get_offsets) into live mode.

The common pattern is to take note of consumed events by adding them into an OffsetMap and resuming the stream from this OffsetMap after an app restart using subscribe_from.

The delivered event stream will be filtered by the subscriptions: an event is included if any of the subscriptions matches.

pub async fn subscribe_from<'_>(
    &'_ self,
    lower_bound: OffsetMap,
    subscriptions: Vec<Subscription>
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
[src]

Subscribe to an unbounded stream of events starting at the given lower bound and continuing past the currently known events (see get_offsets) into live mode.

The common pattern is to take note of consumed events by adding them into an OffsetMap and resuming the stream from this OffsetMap after an app restart.

The delivered event stream will be filtered by the subscriptions: an event is included if any of the subscriptions matches.

pub async fn publish<'_, T>(
    &'_ self,
    semantics: Semantics,
    name: FishName,
    events: impl IntoIterator<Item = T>
) -> Result<(), EventServiceError> where
    T: Serialize + Debug
[src]

Publish the given sequence of event payloads in that order in the stream identified by the given semantics and name. The ActyxOS node will automatically add the local source ID to mark the origin.

Trait Implementations

impl Default for EventService[src]

fn default() -> Self[src]

This will configure a connection to the local Event Service, either an ActyxOS node in development mode or the production ActyxOS node where the app is deployed (in particular, it will inspect the AX_EVENT_SERVICE_URI environment variable and fall back to http://localhost:4454/api/).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<Src, Dst> LosslessTryInto<Dst> for Src where
    Dst: LosslessTryFrom<Src>, 
[src]

impl<Src, Dst> LossyInto<Dst> for Src where
    Dst: LossyFrom<Src>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.