Struct actyxos_sdk::event_service::EventService [−][src]
pub struct EventService { /* fields omitted */ }
Expand description
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
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.
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
.
Obtain the local ActyxOS node ID
pub async fn query_upto(
&self,
upper_bound: OffsetMap,
subscriptions: Vec<Subscription>,
order: Order
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
pub async fn query_upto(
&self,
upper_bound: OffsetMap,
subscriptions: Vec<Subscription>,
order: Order
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
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>
pub async fn query_between(
&self,
lower_bound: OffsetMap,
upper_bound: OffsetMap,
subscriptions: Vec<Subscription>,
order: Order
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
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>
pub async fn subscribe(
&self,
subscriptions: Vec<Subscription>
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
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>
pub async fn subscribe_from(
&self,
lower_bound: OffsetMap,
subscriptions: Vec<Subscription>
) -> Result<impl Stream<Item = Event<Payload>>, EventServiceError>
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,
pub async fn publish<T>(
&self,
semantics: Semantics,
name: FishName,
events: impl IntoIterator<Item = T>
) -> Result<(), EventServiceError> where
T: Serialize + Debug,
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
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
impl !RefUnwindSafe for EventService
impl Send for EventService
impl Sync for EventService
impl Unpin for EventService
impl !UnwindSafe for EventService
Blanket Implementations
Mutably borrows from an owned value. Read more
Performs the conversion.
Performs the conversion.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more