#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppInstanceSettings {
#[prost(bytes = "vec", tag = "3")]
pub json_data: ::prost::alloc::vec::Vec<u8>,
#[prost(map = "string, string", tag = "4")]
pub decrypted_secure_json_data: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(int64, tag = "5")]
pub last_updated_ms: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataSourceInstanceSettings {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub url: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub user: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub database: ::prost::alloc::string::String,
#[prost(bool, tag = "6")]
pub basic_auth_enabled: bool,
#[prost(string, tag = "7")]
pub basic_auth_user: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "8")]
pub json_data: ::prost::alloc::vec::Vec<u8>,
#[prost(map = "string, string", tag = "9")]
pub decrypted_secure_json_data: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(int64, tag = "10")]
pub last_updated_ms: i64,
#[prost(string, tag = "11")]
pub uid: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct User {
#[prost(string, tag = "1")]
pub login: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub email: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub role: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PluginContext {
#[prost(int64, tag = "1")]
pub org_id: i64,
#[prost(string, tag = "2")]
pub plugin_id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub user: ::core::option::Option<User>,
#[prost(message, optional, tag = "4")]
pub app_instance_settings: ::core::option::Option<AppInstanceSettings>,
#[prost(message, optional, tag = "5")]
pub data_source_instance_settings: ::core::option::Option<
DataSourceInstanceSettings,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StringList {
#[prost(string, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CallResourceRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(string, tag = "2")]
pub path: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub method: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub url: ::prost::alloc::string::String,
#[prost(map = "string, message", tag = "5")]
pub headers: ::std::collections::HashMap<::prost::alloc::string::String, StringList>,
#[prost(bytes = "bytes", tag = "6")]
pub body: ::prost::bytes::Bytes,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CallResourceResponse {
#[prost(int32, tag = "1")]
pub code: i32,
#[prost(map = "string, message", tag = "2")]
pub headers: ::std::collections::HashMap<::prost::alloc::string::String, StringList>,
#[prost(bytes = "bytes", tag = "3")]
pub body: ::prost::bytes::Bytes,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimeRange {
#[prost(int64, tag = "1")]
pub from_epoch_ms: i64,
#[prost(int64, tag = "2")]
pub to_epoch_ms: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataQuery {
#[prost(string, tag = "1")]
pub ref_id: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub max_data_points: i64,
#[prost(int64, tag = "3")]
pub interval_ms: i64,
#[prost(message, optional, tag = "4")]
pub time_range: ::core::option::Option<TimeRange>,
#[prost(bytes = "vec", tag = "5")]
pub json: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "6")]
pub query_type: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDataRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(map = "string, string", tag = "2")]
pub headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, repeated, tag = "3")]
pub queries: ::prost::alloc::vec::Vec<DataQuery>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDataResponse {
#[prost(map = "string, message", tag = "1")]
pub responses: ::std::collections::HashMap<
::prost::alloc::string::String,
DataResponse,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataResponse {
#[prost(bytes = "vec", repeated, tag = "1")]
pub frames: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
#[prost(string, tag = "2")]
pub error: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub json_meta: ::prost::alloc::vec::Vec<u8>,
#[prost(int32, tag = "4")]
pub status: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectMetricsRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectMetricsResponse {
#[prost(message, optional, tag = "1")]
pub metrics: ::core::option::Option<collect_metrics_response::Payload>,
}
pub mod collect_metrics_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Payload {
#[prost(bytes = "vec", tag = "1")]
pub prometheus: ::prost::alloc::vec::Vec<u8>,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CheckHealthRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(map = "string, string", tag = "2")]
pub headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CheckHealthResponse {
#[prost(enumeration = "check_health_response::HealthStatus", tag = "1")]
pub status: i32,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub json_details: ::prost::alloc::vec::Vec<u8>,
}
pub mod check_health_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum HealthStatus {
Unknown = 0,
Ok = 1,
Error = 2,
}
impl HealthStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
HealthStatus::Unknown => "UNKNOWN",
HealthStatus::Ok => "OK",
HealthStatus::Error => "ERROR",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"OK" => Some(Self::Ok),
"ERROR" => Some(Self::Error),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubscribeStreamRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(string, tag = "2")]
pub path: ::prost::alloc::string::String,
#[prost(bytes = "bytes", tag = "3")]
pub data: ::prost::bytes::Bytes,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubscribeStreamResponse {
#[prost(enumeration = "subscribe_stream_response::Status", tag = "1")]
pub status: i32,
#[prost(bytes = "vec", tag = "2")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
pub mod subscribe_stream_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Status {
Ok = 0,
NotFound = 1,
PermissionDenied = 2,
}
impl Status {
pub fn as_str_name(&self) -> &'static str {
match self {
Status::Ok => "OK",
Status::NotFound => "NOT_FOUND",
Status::PermissionDenied => "PERMISSION_DENIED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OK" => Some(Self::Ok),
"NOT_FOUND" => Some(Self::NotFound),
"PERMISSION_DENIED" => Some(Self::PermissionDenied),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishStreamRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(string, tag = "2")]
pub path: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishStreamResponse {
#[prost(enumeration = "publish_stream_response::Status", tag = "1")]
pub status: i32,
#[prost(bytes = "vec", tag = "2")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
pub mod publish_stream_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Status {
Ok = 0,
NotFound = 1,
PermissionDenied = 2,
}
impl Status {
pub fn as_str_name(&self) -> &'static str {
match self {
Status::Ok => "OK",
Status::NotFound => "NOT_FOUND",
Status::PermissionDenied => "PERMISSION_DENIED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OK" => Some(Self::Ok),
"NOT_FOUND" => Some(Self::NotFound),
"PERMISSION_DENIED" => Some(Self::PermissionDenied),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RunStreamRequest {
#[prost(message, optional, tag = "1")]
pub plugin_context: ::core::option::Option<PluginContext>,
#[prost(string, tag = "2")]
pub path: ::prost::alloc::string::String,
#[prost(bytes = "bytes", tag = "3")]
pub data: ::prost::bytes::Bytes,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamPacket {
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
pub mod resource_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 ResourceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ResourceClient<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> ResourceClient<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,
) -> ResourceClient<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,
{
ResourceClient::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 call_resource(
&mut self,
request: impl tonic::IntoRequest<super::CallResourceRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::CallResourceResponse>>,
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(
"/pluginv2.Resource/CallResource",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("pluginv2.Resource", "CallResource"));
self.inner.server_streaming(req, path, codec).await
}
}
}
pub mod data_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 DataClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DataClient<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> DataClient<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,
) -> DataClient<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,
{
DataClient::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 query_data(
&mut self,
request: impl tonic::IntoRequest<super::QueryDataRequest>,
) -> std::result::Result<
tonic::Response<super::QueryDataResponse>,
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("/pluginv2.Data/QueryData");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("pluginv2.Data", "QueryData"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod diagnostics_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 DiagnosticsClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DiagnosticsClient<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> DiagnosticsClient<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,
) -> DiagnosticsClient<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,
{
DiagnosticsClient::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 check_health(
&mut self,
request: impl tonic::IntoRequest<super::CheckHealthRequest>,
) -> std::result::Result<
tonic::Response<super::CheckHealthResponse>,
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(
"/pluginv2.Diagnostics/CheckHealth",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("pluginv2.Diagnostics", "CheckHealth"));
self.inner.unary(req, path, codec).await
}
pub async fn collect_metrics(
&mut self,
request: impl tonic::IntoRequest<super::CollectMetricsRequest>,
) -> std::result::Result<
tonic::Response<super::CollectMetricsResponse>,
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(
"/pluginv2.Diagnostics/CollectMetrics",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("pluginv2.Diagnostics", "CollectMetrics"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod stream_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 StreamClient<T> {
inner: tonic::client::Grpc<T>,
}
impl StreamClient<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> StreamClient<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,
) -> StreamClient<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,
{
StreamClient::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 subscribe_stream(
&mut self,
request: impl tonic::IntoRequest<super::SubscribeStreamRequest>,
) -> std::result::Result<
tonic::Response<super::SubscribeStreamResponse>,
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(
"/pluginv2.Stream/SubscribeStream",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("pluginv2.Stream", "SubscribeStream"));
self.inner.unary(req, path, codec).await
}
pub async fn run_stream(
&mut self,
request: impl tonic::IntoRequest<super::RunStreamRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::StreamPacket>>,
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(
"/pluginv2.Stream/RunStream",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("pluginv2.Stream", "RunStream"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn publish_stream(
&mut self,
request: impl tonic::IntoRequest<super::PublishStreamRequest>,
) -> std::result::Result<
tonic::Response<super::PublishStreamResponse>,
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(
"/pluginv2.Stream/PublishStream",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("pluginv2.Stream", "PublishStream"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod resource_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Resource: Send + Sync + 'static {
type CallResourceStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::CallResourceResponse, tonic::Status>,
>
+ Send
+ 'static;
async fn call_resource(
&self,
request: tonic::Request<super::CallResourceRequest>,
) -> std::result::Result<
tonic::Response<Self::CallResourceStream>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct ResourceServer<T: Resource> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Resource> ResourceServer<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(),
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 ResourceServer<T>
where
T: Resource,
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/pluginv2.Resource/CallResource" => {
#[allow(non_camel_case_types)]
struct CallResourceSvc<T: Resource>(pub Arc<T>);
impl<
T: Resource,
> tonic::server::ServerStreamingService<super::CallResourceRequest>
for CallResourceSvc<T> {
type Response = super::CallResourceResponse;
type ResponseStream = T::CallResourceStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CallResourceRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Resource>::call_resource(&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 inner = inner.0;
let method = CallResourceSvc(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.server_streaming(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: Resource> Clone for ResourceServer<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: Resource> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
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: Resource> tonic::server::NamedService for ResourceServer<T> {
const NAME: &'static str = "pluginv2.Resource";
}
}
pub mod data_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Data: Send + Sync + 'static {
async fn query_data(
&self,
request: tonic::Request<super::QueryDataRequest>,
) -> std::result::Result<
tonic::Response<super::QueryDataResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct DataServer<T: Data> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Data> DataServer<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(),
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 DataServer<T>
where
T: Data,
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/pluginv2.Data/QueryData" => {
#[allow(non_camel_case_types)]
struct QueryDataSvc<T: Data>(pub Arc<T>);
impl<T: Data> tonic::server::UnaryService<super::QueryDataRequest>
for QueryDataSvc<T> {
type Response = super::QueryDataResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryDataRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Data>::query_data(&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 inner = inner.0;
let method = QueryDataSvc(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", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Data> Clone for DataServer<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: Data> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
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: Data> tonic::server::NamedService for DataServer<T> {
const NAME: &'static str = "pluginv2.Data";
}
}
pub mod diagnostics_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Diagnostics: Send + Sync + 'static {
async fn check_health(
&self,
request: tonic::Request<super::CheckHealthRequest>,
) -> std::result::Result<
tonic::Response<super::CheckHealthResponse>,
tonic::Status,
>;
async fn collect_metrics(
&self,
request: tonic::Request<super::CollectMetricsRequest>,
) -> std::result::Result<
tonic::Response<super::CollectMetricsResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct DiagnosticsServer<T: Diagnostics> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Diagnostics> DiagnosticsServer<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(),
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 DiagnosticsServer<T>
where
T: Diagnostics,
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/pluginv2.Diagnostics/CheckHealth" => {
#[allow(non_camel_case_types)]
struct CheckHealthSvc<T: Diagnostics>(pub Arc<T>);
impl<
T: Diagnostics,
> tonic::server::UnaryService<super::CheckHealthRequest>
for CheckHealthSvc<T> {
type Response = super::CheckHealthResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CheckHealthRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Diagnostics>::check_health(&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 inner = inner.0;
let method = CheckHealthSvc(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)
}
"/pluginv2.Diagnostics/CollectMetrics" => {
#[allow(non_camel_case_types)]
struct CollectMetricsSvc<T: Diagnostics>(pub Arc<T>);
impl<
T: Diagnostics,
> tonic::server::UnaryService<super::CollectMetricsRequest>
for CollectMetricsSvc<T> {
type Response = super::CollectMetricsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CollectMetricsRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Diagnostics>::collect_metrics(&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 inner = inner.0;
let method = CollectMetricsSvc(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", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Diagnostics> Clone for DiagnosticsServer<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: Diagnostics> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
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: Diagnostics> tonic::server::NamedService for DiagnosticsServer<T> {
const NAME: &'static str = "pluginv2.Diagnostics";
}
}
pub mod stream_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Stream: Send + Sync + 'static {
async fn subscribe_stream(
&self,
request: tonic::Request<super::SubscribeStreamRequest>,
) -> std::result::Result<
tonic::Response<super::SubscribeStreamResponse>,
tonic::Status,
>;
type RunStreamStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::StreamPacket, tonic::Status>,
>
+ Send
+ 'static;
async fn run_stream(
&self,
request: tonic::Request<super::RunStreamRequest>,
) -> std::result::Result<tonic::Response<Self::RunStreamStream>, tonic::Status>;
async fn publish_stream(
&self,
request: tonic::Request<super::PublishStreamRequest>,
) -> std::result::Result<
tonic::Response<super::PublishStreamResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct StreamServer<T: Stream> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Stream> StreamServer<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(),
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 StreamServer<T>
where
T: Stream,
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/pluginv2.Stream/SubscribeStream" => {
#[allow(non_camel_case_types)]
struct SubscribeStreamSvc<T: Stream>(pub Arc<T>);
impl<
T: Stream,
> tonic::server::UnaryService<super::SubscribeStreamRequest>
for SubscribeStreamSvc<T> {
type Response = super::SubscribeStreamResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::SubscribeStreamRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Stream>::subscribe_stream(&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 inner = inner.0;
let method = SubscribeStreamSvc(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)
}
"/pluginv2.Stream/RunStream" => {
#[allow(non_camel_case_types)]
struct RunStreamSvc<T: Stream>(pub Arc<T>);
impl<
T: Stream,
> tonic::server::ServerStreamingService<super::RunStreamRequest>
for RunStreamSvc<T> {
type Response = super::StreamPacket;
type ResponseStream = T::RunStreamStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::RunStreamRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Stream>::run_stream(&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 inner = inner.0;
let method = RunStreamSvc(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.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/pluginv2.Stream/PublishStream" => {
#[allow(non_camel_case_types)]
struct PublishStreamSvc<T: Stream>(pub Arc<T>);
impl<
T: Stream,
> tonic::server::UnaryService<super::PublishStreamRequest>
for PublishStreamSvc<T> {
type Response = super::PublishStreamResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::PublishStreamRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Stream>::publish_stream(&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 inner = inner.0;
let method = PublishStreamSvc(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", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Stream> Clone for StreamServer<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: Stream> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
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: Stream> tonic::server::NamedService for StreamServer<T> {
const NAME: &'static str = "pluginv2.Stream";
}
}