#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Empty {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ActivationIntent {
#[prost(uint64, tag = "1")]
pub host_idx: u64,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub args: ::prost::alloc::vec::Vec<NandoArgument>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NandoArgument {
#[prost(enumeration = "NandoArgumentKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "2")]
pub iptr: ::core::option::Option<IPtr>,
#[prost(message, optional, tag = "3")]
pub value: ::core::option::Option<ScalarValue>,
#[prost(message, repeated, tag = "4")]
pub iptrs: ::prost::alloc::vec::Vec<IPtr>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IPtr {
#[prost(string, tag = "1")]
pub object_id: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub offset: u64,
#[prost(uint64, tag = "3")]
pub size: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScalarValue {
#[prost(enumeration = "ScalarValueKind", tag = "1")]
pub kind: i32,
#[prost(int32, optional, tag = "2")]
pub i32_value: ::core::option::Option<i32>,
#[prost(uint64, optional, tag = "3")]
pub u64_value: ::core::option::Option<u64>,
#[prost(string, optional, tag = "4")]
pub string_value: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bool, optional, tag = "5")]
pub bool_value: ::core::option::Option<bool>,
#[prost(message, repeated, tag = "6")]
pub array_values: ::prost::alloc::vec::Vec<ScalarValue>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SpawnedTask {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub intent: ::core::option::Option<ActivationIntent>,
#[prost(string, optional, tag = "3")]
pub parent_task: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, repeated, tag = "4")]
pub downstream_dependents: ::prost::alloc::vec::Vec<DownstreamDependent>,
#[prost(map = "string, bool", tag = "5")]
pub upstream_control_dependencies: ::std::collections::HashMap<
::prost::alloc::string::String,
bool,
>,
#[prost(bool, optional, tag = "6")]
pub mask_invalidations: ::core::option::Option<bool>,
#[prost(message, optional, tag = "7")]
pub planning_context: ::core::option::Option<PlanningContext>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ActivationResolution {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<NandoStatus>,
#[prost(message, repeated, tag = "2")]
pub result: ::prost::alloc::vec::Vec<NandoResult>,
#[prost(message, repeated, tag = "3")]
pub cacheable_objects: ::prost::alloc::vec::Vec<ObjectVersionPair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NandoStatus {
#[prost(enumeration = "NandoStatusKind", tag = "1")]
pub kind: i32,
#[prost(string, optional, tag = "2")]
pub new_site: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub error_string: ::core::option::Option<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectVersionPair {
#[prost(string, tag = "1")]
pub object_id: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NandoResult {
#[prost(enumeration = "NandoArgumentKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "2")]
pub iptr: ::core::option::Option<IPtr>,
#[prost(message, optional, tag = "3")]
pub value: ::core::option::Option<ScalarValue>,
#[prost(string, optional, tag = "4")]
pub spawned_epic_id: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, repeated, tag = "5")]
pub iptrs: ::prost::alloc::vec::Vec<IPtr>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskCompletion {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub tasks_to_notify: ::prost::alloc::vec::Vec<DownstreamDependent>,
#[prost(message, repeated, tag = "3")]
pub results: ::prost::alloc::vec::Vec<NandoResult>,
#[prost(message, repeated, tag = "4")]
pub subgraph_allocations: ::prost::alloc::vec::Vec<Allocation>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Allocation {
#[prost(uint64, tag = "1")]
pub allocation_host_idx: u64,
#[prost(message, optional, tag = "2")]
pub allocated_object: ::core::option::Option<IPtr>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownstreamDependent {
#[prost(enumeration = "DownstreamDependentKind", tag = "1")]
pub kind: i32,
#[prost(string, tag = "2")]
pub dependency_id: ::prost::alloc::string::String,
#[prost(uint32, optional, tag = "3")]
pub argument_idx: ::core::option::Option<u32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AssumeOwnershipRequest {
#[prost(string, tag = "1")]
pub object_id: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub first_version: u64,
#[prost(bool, tag = "3")]
pub get_signature: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AssumeOwnershipResponse {
#[prost(bytes = "vec", tag = "1")]
pub signature: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MoveOwnershipRequest {
#[prost(string, repeated, tag = "1")]
pub object_refs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "2")]
pub new_host: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MoveOwnershipResponse {
#[prost(message, repeated, tag = "1")]
pub whomstone_versions: ::prost::alloc::vec::Vec<ObjectVersionPair>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FaultCacheRequest {
#[prost(uint64, tag = "1")]
pub host_idx: u64,
#[prost(string, tag = "2")]
pub original_object_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub cached_object_id: ::prost::alloc::string::String,
#[prost(uint64, tag = "4")]
pub version: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskGraph {
#[prost(message, repeated, tag = "1")]
pub graph_tasks: ::prost::alloc::vec::Vec<SpawnedTask>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskGraphResolution {
#[prost(message, repeated, tag = "1")]
pub activation_resolutions: ::prost::alloc::vec::Vec<ActivationResolution>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CacheMapping {
#[prost(message, optional, tag = "1")]
pub original_object: ::core::option::Option<IPtr>,
#[prost(message, optional, tag = "2")]
pub cache_object: ::core::option::Option<IPtr>,
#[prost(uint64, tag = "3")]
pub version: u64,
#[prost(uint64, tag = "4")]
pub original_owner_idx: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PlanningContext {
#[prost(uint64, tag = "1")]
pub idx: u64,
#[prost(string, tag = "2")]
pub plan_key: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum NandoArgumentKind {
Ref = 0,
Value = 1,
Epic = 2,
Nil = 3,
MRef = 4,
}
impl NandoArgumentKind {
pub fn as_str_name(&self) -> &'static str {
match self {
NandoArgumentKind::Ref => "REF",
NandoArgumentKind::Value => "VALUE",
NandoArgumentKind::Epic => "EPIC",
NandoArgumentKind::Nil => "NIL",
NandoArgumentKind::MRef => "M_REF",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"REF" => Some(Self::Ref),
"VALUE" => Some(Self::Value),
"EPIC" => Some(Self::Epic),
"NIL" => Some(Self::Nil),
"M_REF" => Some(Self::MRef),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ScalarValueKind {
I32 = 0,
U64 = 1,
Usize = 2,
U128 = 3,
String = 4,
U8 = 5,
Bool = 6,
Array = 7,
}
impl ScalarValueKind {
pub fn as_str_name(&self) -> &'static str {
match self {
ScalarValueKind::I32 => "I32",
ScalarValueKind::U64 => "U64",
ScalarValueKind::Usize => "USIZE",
ScalarValueKind::U128 => "U128",
ScalarValueKind::String => "STRING",
ScalarValueKind::U8 => "U8",
ScalarValueKind::Bool => "BOOL",
ScalarValueKind::Array => "ARRAY",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"I32" => Some(Self::I32),
"U64" => Some(Self::U64),
"USIZE" => Some(Self::Usize),
"U128" => Some(Self::U128),
"STRING" => Some(Self::String),
"U8" => Some(Self::U8),
"BOOL" => Some(Self::Bool),
"ARRAY" => Some(Self::Array),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum NandoStatusKind {
Success = 0,
RecomputedSite = 1,
Error = 2,
}
impl NandoStatusKind {
pub fn as_str_name(&self) -> &'static str {
match self {
NandoStatusKind::Success => "SUCCESS",
NandoStatusKind::RecomputedSite => "RECOMPUTED_SITE",
NandoStatusKind::Error => "ERROR",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SUCCESS" => Some(Self::Success),
"RECOMPUTED_SITE" => Some(Self::RecomputedSite),
"ERROR" => Some(Self::Error),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DownstreamDependentKind {
Data = 0,
Control = 1,
Parent = 2,
}
impl DownstreamDependentKind {
pub fn as_str_name(&self) -> &'static str {
match self {
DownstreamDependentKind::Data => "DATA",
DownstreamDependentKind::Control => "CONTROL",
DownstreamDependentKind::Parent => "PARENT",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DATA" => Some(Self::Data),
"CONTROL" => Some(Self::Control),
"PARENT" => Some(Self::Parent),
_ => None,
}
}
}
pub mod worker_api_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 WorkerApiClient<T> {
inner: tonic::client::Grpc<T>,
}
impl WorkerApiClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> WorkerApiClient<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,
) -> WorkerApiClient<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,
{
WorkerApiClient::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
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn schedule_nando(
&mut self,
request: impl tonic::IntoRequest<super::ActivationIntent>,
) -> std::result::Result<
tonic::Response<super::ActivationResolution>,
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(
"/ww.WorkerApi/ScheduleNando",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "ScheduleNando"));
self.inner.unary(req, path, codec).await
}
pub async fn schedule_spawned_task(
&mut self,
request: impl tonic::IntoRequest<super::SpawnedTask>,
) -> std::result::Result<
tonic::Response<super::ActivationResolution>,
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(
"/ww.WorkerApi/ScheduleSpawnedTask",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "ScheduleSpawnedTask"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_task_completion(
&mut self,
request: impl tonic::IntoRequest<super::TaskCompletion>,
) -> std::result::Result<tonic::Response<super::Empty>, 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(
"/ww.WorkerApi/HandleTaskCompletion",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "HandleTaskCompletion"));
self.inner.unary(req, path, codec).await
}
pub async fn assume_ownership(
&mut self,
request: impl tonic::IntoRequest<super::AssumeOwnershipRequest>,
) -> std::result::Result<
tonic::Response<super::AssumeOwnershipResponse>,
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(
"/ww.WorkerApi/AssumeOwnership",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "AssumeOwnership"));
self.inner.unary(req, path, codec).await
}
pub async fn move_ownership(
&mut self,
request: impl tonic::IntoRequest<super::MoveOwnershipRequest>,
) -> std::result::Result<
tonic::Response<super::MoveOwnershipResponse>,
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(
"/ww.WorkerApi/MoveOwnership",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "MoveOwnership"));
self.inner.unary(req, path, codec).await
}
pub async fn fault_shared_cache(
&mut self,
request: impl tonic::IntoRequest<super::FaultCacheRequest>,
) -> std::result::Result<tonic::Response<super::Empty>, 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(
"/ww.WorkerApi/FaultSharedCache",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "FaultSharedCache"));
self.inner.unary(req, path, codec).await
}
pub async fn schedule_task_graph(
&mut self,
request: impl tonic::IntoRequest<super::TaskGraph>,
) -> std::result::Result<
tonic::Response<super::TaskGraphResolution>,
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(
"/ww.WorkerApi/ScheduleTaskGraph",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "ScheduleTaskGraph"));
self.inner.unary(req, path, codec).await
}
pub async fn add_cache_mapping(
&mut self,
request: impl tonic::IntoRequest<super::CacheMapping>,
) -> std::result::Result<tonic::Response<super::Empty>, 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(
"/ww.WorkerApi/AddCacheMapping",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("ww.WorkerApi", "AddCacheMapping"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod worker_api_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait WorkerApi: Send + Sync + 'static {
async fn schedule_nando(
&self,
request: tonic::Request<super::ActivationIntent>,
) -> std::result::Result<
tonic::Response<super::ActivationResolution>,
tonic::Status,
>;
async fn schedule_spawned_task(
&self,
request: tonic::Request<super::SpawnedTask>,
) -> std::result::Result<
tonic::Response<super::ActivationResolution>,
tonic::Status,
>;
async fn handle_task_completion(
&self,
request: tonic::Request<super::TaskCompletion>,
) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status>;
async fn assume_ownership(
&self,
request: tonic::Request<super::AssumeOwnershipRequest>,
) -> std::result::Result<
tonic::Response<super::AssumeOwnershipResponse>,
tonic::Status,
>;
async fn move_ownership(
&self,
request: tonic::Request<super::MoveOwnershipRequest>,
) -> std::result::Result<
tonic::Response<super::MoveOwnershipResponse>,
tonic::Status,
>;
async fn fault_shared_cache(
&self,
request: tonic::Request<super::FaultCacheRequest>,
) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status>;
async fn schedule_task_graph(
&self,
request: tonic::Request<super::TaskGraph>,
) -> std::result::Result<
tonic::Response<super::TaskGraphResolution>,
tonic::Status,
>;
async fn add_cache_mapping(
&self,
request: tonic::Request<super::CacheMapping>,
) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status>;
}
#[derive(Debug)]
pub struct WorkerApiServer<T: WorkerApi> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T: WorkerApi> WorkerApiServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
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
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for WorkerApiServer<T>
where
T: WorkerApi,
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<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/ww.WorkerApi/ScheduleNando" => {
#[allow(non_camel_case_types)]
struct ScheduleNandoSvc<T: WorkerApi>(pub Arc<T>);
impl<
T: WorkerApi,
> tonic::server::UnaryService<super::ActivationIntent>
for ScheduleNandoSvc<T> {
type Response = super::ActivationResolution;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ActivationIntent>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::schedule_nando(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ScheduleNandoSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/ScheduleSpawnedTask" => {
#[allow(non_camel_case_types)]
struct ScheduleSpawnedTaskSvc<T: WorkerApi>(pub Arc<T>);
impl<T: WorkerApi> tonic::server::UnaryService<super::SpawnedTask>
for ScheduleSpawnedTaskSvc<T> {
type Response = super::ActivationResolution;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::SpawnedTask>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::schedule_spawned_task(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ScheduleSpawnedTaskSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/HandleTaskCompletion" => {
#[allow(non_camel_case_types)]
struct HandleTaskCompletionSvc<T: WorkerApi>(pub Arc<T>);
impl<T: WorkerApi> tonic::server::UnaryService<super::TaskCompletion>
for HandleTaskCompletionSvc<T> {
type Response = super::Empty;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TaskCompletion>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::handle_task_completion(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleTaskCompletionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/AssumeOwnership" => {
#[allow(non_camel_case_types)]
struct AssumeOwnershipSvc<T: WorkerApi>(pub Arc<T>);
impl<
T: WorkerApi,
> tonic::server::UnaryService<super::AssumeOwnershipRequest>
for AssumeOwnershipSvc<T> {
type Response = super::AssumeOwnershipResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AssumeOwnershipRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::assume_ownership(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = AssumeOwnershipSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/MoveOwnership" => {
#[allow(non_camel_case_types)]
struct MoveOwnershipSvc<T: WorkerApi>(pub Arc<T>);
impl<
T: WorkerApi,
> tonic::server::UnaryService<super::MoveOwnershipRequest>
for MoveOwnershipSvc<T> {
type Response = super::MoveOwnershipResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MoveOwnershipRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::move_ownership(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = MoveOwnershipSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/FaultSharedCache" => {
#[allow(non_camel_case_types)]
struct FaultSharedCacheSvc<T: WorkerApi>(pub Arc<T>);
impl<
T: WorkerApi,
> tonic::server::UnaryService<super::FaultCacheRequest>
for FaultSharedCacheSvc<T> {
type Response = super::Empty;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::FaultCacheRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::fault_shared_cache(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = FaultSharedCacheSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/ScheduleTaskGraph" => {
#[allow(non_camel_case_types)]
struct ScheduleTaskGraphSvc<T: WorkerApi>(pub Arc<T>);
impl<T: WorkerApi> tonic::server::UnaryService<super::TaskGraph>
for ScheduleTaskGraphSvc<T> {
type Response = super::TaskGraphResolution;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TaskGraph>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::schedule_task_graph(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ScheduleTaskGraphSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/ww.WorkerApi/AddCacheMapping" => {
#[allow(non_camel_case_types)]
struct AddCacheMappingSvc<T: WorkerApi>(pub Arc<T>);
impl<T: WorkerApi> tonic::server::UnaryService<super::CacheMapping>
for AddCacheMappingSvc<T> {
type Response = super::Empty;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CacheMapping>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as WorkerApi>::add_cache_mapping(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = AddCacheMappingSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
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", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: WorkerApi> Clone for WorkerApiServer<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,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
impl<T: WorkerApi> tonic::server::NamedService for WorkerApiServer<T> {
const NAME: &'static str = "ww.WorkerApi";
}
}