#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScheduleEventRequest {
#[prost(int64, tag = "1")]
pub instant: i64,
#[prost(message, optional, tag = "2")]
pub event: ::core::option::Option<Event>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RescheduleEventRequest {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub instant: i64,
#[prost(message, optional, tag = "3")]
pub event: ::core::option::Option<Event>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CancelScheduledEventRequest {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScheduleToken {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetFirstTokenRequest {}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetLastTokenRequest {}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetTokenAtRequest {
#[prost(int64, tag = "1")]
pub instant: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackingToken {
#[prost(int64, tag = "1")]
pub token: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EventWithToken {
#[prost(int64, tag = "1")]
pub token: i64,
#[prost(message, optional, tag = "2")]
pub event: ::core::option::Option<Event>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryEventsRequest {
#[prost(string, tag = "1")]
pub query: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub number_of_permits: i64,
#[prost(bool, tag = "3")]
pub live_events: bool,
#[prost(bool, tag = "4")]
pub force_read_from_leader: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryEventsResponse {
#[prost(oneof = "query_events_response::Data", tags = "1, 2, 3")]
pub data: ::core::option::Option<query_events_response::Data>,
}
pub mod query_events_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
#[prost(message, tag = "1")]
Columns(super::ColumnsResponse),
#[prost(message, tag = "2")]
Row(super::RowResponse),
#[prost(message, tag = "3")]
FilesCompleted(super::Confirmation),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ColumnsResponse {
#[prost(string, repeated, tag = "1")]
pub column: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RowResponse {
#[prost(message, repeated, tag = "1")]
pub id_values: ::prost::alloc::vec::Vec<QueryValue>,
#[prost(message, repeated, tag = "2")]
pub sort_values: ::prost::alloc::vec::Vec<QueryValue>,
#[prost(map = "string, message", tag = "3")]
pub values: ::std::collections::HashMap<::prost::alloc::string::String, QueryValue>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadHighestSequenceNrRequest {
#[prost(string, tag = "1")]
pub aggregate_id: ::prost::alloc::string::String,
#[prost(int64, tag = "3")]
pub from_sequence_nr: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadHighestSequenceNrResponse {
#[prost(int64, tag = "1")]
pub to_sequence_nr: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Confirmation {
#[prost(bool, tag = "1")]
pub success: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAggregateEventsRequest {
#[prost(string, tag = "1")]
pub aggregate_id: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub initial_sequence: i64,
#[prost(bool, tag = "3")]
pub allow_snapshots: bool,
#[prost(int64, tag = "4")]
pub max_sequence: i64,
#[prost(int64, tag = "5")]
pub min_token: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAggregateSnapshotsRequest {
#[prost(string, tag = "1")]
pub aggregate_id: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub initial_sequence: i64,
#[prost(int64, tag = "3")]
pub max_sequence: i64,
#[prost(int32, tag = "4")]
pub max_results: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetEventsRequest {
#[prost(int64, tag = "1")]
pub tracking_token: i64,
#[prost(int64, tag = "2")]
pub number_of_permits: i64,
#[prost(string, tag = "3")]
pub client_id: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub component_name: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub processor: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "6")]
pub blacklist: ::prost::alloc::vec::Vec<PayloadDescription>,
#[prost(bool, tag = "7")]
pub force_read_from_leader: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Event {
#[prost(string, tag = "1")]
pub message_identifier: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub aggregate_identifier: ::prost::alloc::string::String,
#[prost(int64, tag = "3")]
pub aggregate_sequence_number: i64,
#[prost(string, tag = "4")]
pub aggregate_type: ::prost::alloc::string::String,
#[prost(int64, tag = "5")]
pub timestamp: i64,
#[prost(message, optional, tag = "6")]
pub payload: ::core::option::Option<super::common::SerializedObject>,
#[prost(map = "string, message", tag = "7")]
pub meta_data: ::std::collections::HashMap<
::prost::alloc::string::String,
super::common::MetaDataValue,
>,
#[prost(bool, tag = "8")]
pub snapshot: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryValue {
#[prost(oneof = "query_value::Data", tags = "1, 2, 3, 4")]
pub data: ::core::option::Option<query_value::Data>,
}
pub mod query_value {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
#[prost(string, tag = "1")]
TextValue(::prost::alloc::string::String),
#[prost(sint64, tag = "2")]
NumberValue(i64),
#[prost(bool, tag = "3")]
BooleanValue(bool),
#[prost(double, tag = "4")]
DoubleValue(f64),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PayloadDescription {
#[prost(string, tag = "1")]
pub r#type: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub revision: ::prost::alloc::string::String,
}
pub mod event_store_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct EventStoreClient<T> {
inner: tonic::client::Grpc<T>,
}
impl EventStoreClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> EventStoreClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> EventStoreClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
EventStoreClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
pub async fn append_event(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::Event>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/AppendEvent",
);
self.inner
.client_streaming(request.into_streaming_request(), path, codec)
.await
}
pub async fn append_snapshot(
&mut self,
request: impl tonic::IntoRequest<super::Event>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/AppendSnapshot",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn list_aggregate_events(
&mut self,
request: impl tonic::IntoRequest<super::GetAggregateEventsRequest>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::Event>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/ListAggregateEvents",
);
self.inner.server_streaming(request.into_request(), path, codec).await
}
pub async fn list_aggregate_snapshots(
&mut self,
request: impl tonic::IntoRequest<super::GetAggregateSnapshotsRequest>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::Event>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/ListAggregateSnapshots",
);
self.inner.server_streaming(request.into_request(), path, codec).await
}
pub async fn list_events(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::GetEventsRequest>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::EventWithToken>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/ListEvents",
);
self.inner.streaming(request.into_streaming_request(), path, codec).await
}
pub async fn read_highest_sequence_nr(
&mut self,
request: impl tonic::IntoRequest<super::ReadHighestSequenceNrRequest>,
) -> Result<
tonic::Response<super::ReadHighestSequenceNrResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/ReadHighestSequenceNr",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn query_events(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::QueryEventsRequest,
>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::QueryEventsResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/QueryEvents",
);
self.inner.streaming(request.into_streaming_request(), path, codec).await
}
pub async fn get_first_token(
&mut self,
request: impl tonic::IntoRequest<super::GetFirstTokenRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/GetFirstToken",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn get_last_token(
&mut self,
request: impl tonic::IntoRequest<super::GetLastTokenRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/GetLastToken",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn get_token_at(
&mut self,
request: impl tonic::IntoRequest<super::GetTokenAtRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventStore/GetTokenAt",
);
self.inner.unary(request.into_request(), path, codec).await
}
}
}
pub mod event_scheduler_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct EventSchedulerClient<T> {
inner: tonic::client::Grpc<T>,
}
impl EventSchedulerClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> EventSchedulerClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> EventSchedulerClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
EventSchedulerClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
pub async fn schedule_event(
&mut self,
request: impl tonic::IntoRequest<super::ScheduleEventRequest>,
) -> Result<tonic::Response<super::ScheduleToken>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventScheduler/ScheduleEvent",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn reschedule_event(
&mut self,
request: impl tonic::IntoRequest<super::RescheduleEventRequest>,
) -> Result<tonic::Response<super::ScheduleToken>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventScheduler/RescheduleEvent",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn cancel_scheduled_event(
&mut self,
request: impl tonic::IntoRequest<super::CancelScheduledEventRequest>,
) -> Result<
tonic::Response<super::super::common::InstructionAck>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.axoniq.axonserver.grpc.event.EventScheduler/CancelScheduledEvent",
);
self.inner.unary(request.into_request(), path, codec).await
}
}
}
pub mod event_store_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait EventStore: Send + Sync + 'static {
async fn append_event(
&self,
request: tonic::Request<tonic::Streaming<super::Event>>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status>;
async fn append_snapshot(
&self,
request: tonic::Request<super::Event>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status>;
type ListAggregateEventsStream: futures_core::Stream<
Item = Result<super::Event, tonic::Status>,
>
+ Send
+ 'static;
async fn list_aggregate_events(
&self,
request: tonic::Request<super::GetAggregateEventsRequest>,
) -> Result<tonic::Response<Self::ListAggregateEventsStream>, tonic::Status>;
type ListAggregateSnapshotsStream: futures_core::Stream<
Item = Result<super::Event, tonic::Status>,
>
+ Send
+ 'static;
async fn list_aggregate_snapshots(
&self,
request: tonic::Request<super::GetAggregateSnapshotsRequest>,
) -> Result<tonic::Response<Self::ListAggregateSnapshotsStream>, tonic::Status>;
type ListEventsStream: futures_core::Stream<
Item = Result<super::EventWithToken, tonic::Status>,
>
+ Send
+ 'static;
async fn list_events(
&self,
request: tonic::Request<tonic::Streaming<super::GetEventsRequest>>,
) -> Result<tonic::Response<Self::ListEventsStream>, tonic::Status>;
async fn read_highest_sequence_nr(
&self,
request: tonic::Request<super::ReadHighestSequenceNrRequest>,
) -> Result<
tonic::Response<super::ReadHighestSequenceNrResponse>,
tonic::Status,
>;
type QueryEventsStream: futures_core::Stream<
Item = Result<super::QueryEventsResponse, tonic::Status>,
>
+ Send
+ 'static;
async fn query_events(
&self,
request: tonic::Request<tonic::Streaming<super::QueryEventsRequest>>,
) -> Result<tonic::Response<Self::QueryEventsStream>, tonic::Status>;
async fn get_first_token(
&self,
request: tonic::Request<super::GetFirstTokenRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status>;
async fn get_last_token(
&self,
request: tonic::Request<super::GetLastTokenRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status>;
async fn get_token_at(
&self,
request: tonic::Request<super::GetTokenAtRequest>,
) -> Result<tonic::Response<super::TrackingToken>, tonic::Status>;
}
#[derive(Debug)]
pub struct EventStoreServer<T: EventStore> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: EventStore> EventStoreServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for EventStoreServer<T>
where
T: EventStore,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/io.axoniq.axonserver.grpc.event.EventStore/AppendEvent" => {
#[allow(non_camel_case_types)]
struct AppendEventSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::ClientStreamingService<super::Event>
for AppendEventSvc<T> {
type Response = super::Confirmation;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<tonic::Streaming<super::Event>>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).append_event(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AppendEventSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.client_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/AppendSnapshot" => {
#[allow(non_camel_case_types)]
struct AppendSnapshotSvc<T: EventStore>(pub Arc<T>);
impl<T: EventStore> tonic::server::UnaryService<super::Event>
for AppendSnapshotSvc<T> {
type Response = super::Confirmation;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::Event>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).append_snapshot(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AppendSnapshotSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/ListAggregateEvents" => {
#[allow(non_camel_case_types)]
struct ListAggregateEventsSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::ServerStreamingService<
super::GetAggregateEventsRequest,
> for ListAggregateEventsSvc<T> {
type Response = super::Event;
type ResponseStream = T::ListAggregateEventsStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAggregateEventsRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).list_aggregate_events(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ListAggregateEventsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/ListAggregateSnapshots" => {
#[allow(non_camel_case_types)]
struct ListAggregateSnapshotsSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::ServerStreamingService<
super::GetAggregateSnapshotsRequest,
> for ListAggregateSnapshotsSvc<T> {
type Response = super::Event;
type ResponseStream = T::ListAggregateSnapshotsStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAggregateSnapshotsRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).list_aggregate_snapshots(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ListAggregateSnapshotsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/ListEvents" => {
#[allow(non_camel_case_types)]
struct ListEventsSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::StreamingService<super::GetEventsRequest>
for ListEventsSvc<T> {
type Response = super::EventWithToken;
type ResponseStream = T::ListEventsStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::GetEventsRequest>,
>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).list_events(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ListEventsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/ReadHighestSequenceNr" => {
#[allow(non_camel_case_types)]
struct ReadHighestSequenceNrSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::UnaryService<super::ReadHighestSequenceNrRequest>
for ReadHighestSequenceNrSvc<T> {
type Response = super::ReadHighestSequenceNrResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ReadHighestSequenceNrRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).read_highest_sequence_nr(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ReadHighestSequenceNrSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/QueryEvents" => {
#[allow(non_camel_case_types)]
struct QueryEventsSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::StreamingService<super::QueryEventsRequest>
for QueryEventsSvc<T> {
type Response = super::QueryEventsResponse;
type ResponseStream = T::QueryEventsStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::QueryEventsRequest>,
>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).query_events(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = QueryEventsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/GetFirstToken" => {
#[allow(non_camel_case_types)]
struct GetFirstTokenSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::UnaryService<super::GetFirstTokenRequest>
for GetFirstTokenSvc<T> {
type Response = super::TrackingToken;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetFirstTokenRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).get_first_token(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetFirstTokenSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/GetLastToken" => {
#[allow(non_camel_case_types)]
struct GetLastTokenSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::UnaryService<super::GetLastTokenRequest>
for GetLastTokenSvc<T> {
type Response = super::TrackingToken;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetLastTokenRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).get_last_token(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetLastTokenSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventStore/GetTokenAt" => {
#[allow(non_camel_case_types)]
struct GetTokenAtSvc<T: EventStore>(pub Arc<T>);
impl<
T: EventStore,
> tonic::server::UnaryService<super::GetTokenAtRequest>
for GetTokenAtSvc<T> {
type Response = super::TrackingToken;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetTokenAtRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).get_token_at(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetTokenAtSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: EventStore> Clone for EventStoreServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
}
}
}
impl<T: EventStore> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: EventStore> tonic::server::NamedService for EventStoreServer<T> {
const NAME: &'static str = "io.axoniq.axonserver.grpc.event.EventStore";
}
}
pub mod event_scheduler_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait EventScheduler: Send + Sync + 'static {
async fn schedule_event(
&self,
request: tonic::Request<super::ScheduleEventRequest>,
) -> Result<tonic::Response<super::ScheduleToken>, tonic::Status>;
async fn reschedule_event(
&self,
request: tonic::Request<super::RescheduleEventRequest>,
) -> Result<tonic::Response<super::ScheduleToken>, tonic::Status>;
async fn cancel_scheduled_event(
&self,
request: tonic::Request<super::CancelScheduledEventRequest>,
) -> Result<
tonic::Response<super::super::common::InstructionAck>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct EventSchedulerServer<T: EventScheduler> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: EventScheduler> EventSchedulerServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for EventSchedulerServer<T>
where
T: EventScheduler,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/io.axoniq.axonserver.grpc.event.EventScheduler/ScheduleEvent" => {
#[allow(non_camel_case_types)]
struct ScheduleEventSvc<T: EventScheduler>(pub Arc<T>);
impl<
T: EventScheduler,
> tonic::server::UnaryService<super::ScheduleEventRequest>
for ScheduleEventSvc<T> {
type Response = super::ScheduleToken;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ScheduleEventRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).schedule_event(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ScheduleEventSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventScheduler/RescheduleEvent" => {
#[allow(non_camel_case_types)]
struct RescheduleEventSvc<T: EventScheduler>(pub Arc<T>);
impl<
T: EventScheduler,
> tonic::server::UnaryService<super::RescheduleEventRequest>
for RescheduleEventSvc<T> {
type Response = super::ScheduleToken;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::RescheduleEventRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).reschedule_event(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = RescheduleEventSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.axoniq.axonserver.grpc.event.EventScheduler/CancelScheduledEvent" => {
#[allow(non_camel_case_types)]
struct CancelScheduledEventSvc<T: EventScheduler>(pub Arc<T>);
impl<
T: EventScheduler,
> tonic::server::UnaryService<super::CancelScheduledEventRequest>
for CancelScheduledEventSvc<T> {
type Response = super::super::common::InstructionAck;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CancelScheduledEventRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).cancel_scheduled_event(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = CancelScheduledEventSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: EventScheduler> Clone for EventSchedulerServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
}
}
}
impl<T: EventScheduler> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: EventScheduler> tonic::server::NamedService for EventSchedulerServer<T> {
const NAME: &'static str = "io.axoniq.axonserver.grpc.event.EventScheduler";
}
}