moving ECB to a separate proto file
This commit is contained in:
@@ -217,6 +217,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&[
|
||||
"proto/common.proto",
|
||||
"proto/document_data.proto",
|
||||
"proto/ecb.proto",
|
||||
"proto/adresar.proto",
|
||||
"proto/analytics.proto",
|
||||
"proto/auth.proto",
|
||||
@@ -243,6 +244,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
for proto in [
|
||||
"proto/common.proto",
|
||||
"proto/document_data.proto",
|
||||
"proto/ecb.proto",
|
||||
"proto/adresar.proto",
|
||||
"proto/analytics.proto",
|
||||
"proto/auth.proto",
|
||||
|
||||
67
common/proto/ecb.proto
Normal file
67
common/proto/ecb.proto
Normal file
@@ -0,0 +1,67 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package komp_ac.ecb;
|
||||
|
||||
// Read-only access to ECB conversion audit evidence.
|
||||
//
|
||||
// This service exists for manual visual verification. It exposes conversions
|
||||
// already recorded by backend posting workflows and never recalculates money.
|
||||
service EcbService {
|
||||
// List immutable ECB conversion evidence for one money value.
|
||||
rpc ListEcbConversionEvidence(ListEcbConversionEvidenceRequest)
|
||||
returns (ListEcbConversionEvidenceResponse);
|
||||
}
|
||||
|
||||
// Identify one logical money cell whose conversion history should be inspected.
|
||||
message ListEcbConversionEvidenceRequest {
|
||||
// Required. Profile containing the table.
|
||||
string profile_name = 1;
|
||||
|
||||
// Required. Logical table name within the profile.
|
||||
string table_name = 2;
|
||||
|
||||
// Required. Dynamic table row id.
|
||||
int64 record_id = 3;
|
||||
|
||||
// Required. Current display name of the money column. The server resolves it
|
||||
// to the stable physical column name used by immutable evidence.
|
||||
string column_name = 4;
|
||||
|
||||
// Optional. Maximum rows to return. Zero uses 100; maximum is 500.
|
||||
int32 limit = 5;
|
||||
|
||||
// Optional cursor. Return evidence ids lower than this value.
|
||||
optional int64 before_evidence_id = 6;
|
||||
}
|
||||
|
||||
// One immutable explanation of how a posted EUR value was determined.
|
||||
message EcbConversionEvidence {
|
||||
int64 evidence_id = 1;
|
||||
string original_amount = 2;
|
||||
string original_currency = 3;
|
||||
string eur_amount = 4;
|
||||
string conversion_context = 5;
|
||||
string anchor_date = 6;
|
||||
string determination_method = 7;
|
||||
string rounding_method = 8;
|
||||
optional string rate_date = 9;
|
||||
optional string units_per_eur = 10;
|
||||
optional int64 rate_observation_id = 11;
|
||||
optional string observation_hash = 12;
|
||||
optional string source_payload_hash = 13;
|
||||
optional string rate_fetched_at = 14;
|
||||
optional int64 import_batch_id = 15;
|
||||
optional string source_endpoint = 16;
|
||||
string evidence_created_at = 17;
|
||||
}
|
||||
|
||||
message ListEcbConversionEvidenceResponse {
|
||||
// True when at least one evidence row for this cell used an ECB rate.
|
||||
bool has_exchange = 1;
|
||||
|
||||
// Newest-first immutable history for this page.
|
||||
repeated EcbConversionEvidence evidence = 2;
|
||||
|
||||
// True when another page exists using the last evidence_id as the cursor.
|
||||
bool has_more = 3;
|
||||
}
|
||||
@@ -23,6 +23,9 @@ pub mod proto {
|
||||
pub mod document_data {
|
||||
include!("proto/komp_ac.document_data.rs");
|
||||
}
|
||||
pub mod ecb {
|
||||
include!("proto/komp_ac.ecb.rs");
|
||||
}
|
||||
pub mod table_structure {
|
||||
include!("proto/komp_ac.table_structure.rs");
|
||||
}
|
||||
|
||||
Binary file not shown.
395
common/src/proto/komp_ac.ecb.rs
Normal file
395
common/src/proto/komp_ac.ecb.rs
Normal file
@@ -0,0 +1,395 @@
|
||||
// This file is @generated by prost-build.
|
||||
/// Identify one logical money cell whose conversion history should be inspected.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct ListEcbConversionEvidenceRequest {
|
||||
/// Required. Profile containing the table.
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
/// Required. Logical table name within the profile.
|
||||
#[prost(string, tag = "2")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
/// Required. Dynamic table row id.
|
||||
#[prost(int64, tag = "3")]
|
||||
pub record_id: i64,
|
||||
/// Required. Current display name of the money column. The server resolves it
|
||||
/// to the stable physical column name used by immutable evidence.
|
||||
#[prost(string, tag = "4")]
|
||||
pub column_name: ::prost::alloc::string::String,
|
||||
/// Optional. Maximum rows to return. Zero uses 100; maximum is 500.
|
||||
#[prost(int32, tag = "5")]
|
||||
pub limit: i32,
|
||||
/// Optional cursor. Return evidence ids lower than this value.
|
||||
#[prost(int64, optional, tag = "6")]
|
||||
pub before_evidence_id: ::core::option::Option<i64>,
|
||||
}
|
||||
/// One immutable explanation of how a posted EUR value was determined.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct EcbConversionEvidence {
|
||||
#[prost(int64, tag = "1")]
|
||||
pub evidence_id: i64,
|
||||
#[prost(string, tag = "2")]
|
||||
pub original_amount: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub original_currency: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub eur_amount: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub conversion_context: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "6")]
|
||||
pub anchor_date: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "7")]
|
||||
pub determination_method: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "8")]
|
||||
pub rounding_method: ::prost::alloc::string::String,
|
||||
#[prost(string, optional, tag = "9")]
|
||||
pub rate_date: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(string, optional, tag = "10")]
|
||||
pub units_per_eur: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(int64, optional, tag = "11")]
|
||||
pub rate_observation_id: ::core::option::Option<i64>,
|
||||
#[prost(string, optional, tag = "12")]
|
||||
pub observation_hash: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(string, optional, tag = "13")]
|
||||
pub source_payload_hash: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(string, optional, tag = "14")]
|
||||
pub rate_fetched_at: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(int64, optional, tag = "15")]
|
||||
pub import_batch_id: ::core::option::Option<i64>,
|
||||
#[prost(string, optional, tag = "16")]
|
||||
pub source_endpoint: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(string, tag = "17")]
|
||||
pub evidence_created_at: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ListEcbConversionEvidenceResponse {
|
||||
/// True when at least one evidence row for this cell used an ECB rate.
|
||||
#[prost(bool, tag = "1")]
|
||||
pub has_exchange: bool,
|
||||
/// Newest-first immutable history for this page.
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub evidence: ::prost::alloc::vec::Vec<EcbConversionEvidence>,
|
||||
/// True when another page exists using the last evidence_id as the cursor.
|
||||
#[prost(bool, tag = "3")]
|
||||
pub has_more: bool,
|
||||
}
|
||||
/// Generated client implementations.
|
||||
pub mod ecb_service_client {
|
||||
#![allow(
|
||||
unused_variables,
|
||||
dead_code,
|
||||
missing_docs,
|
||||
clippy::wildcard_imports,
|
||||
clippy::let_unit_value,
|
||||
)]
|
||||
use tonic::codegen::*;
|
||||
use tonic::codegen::http::Uri;
|
||||
/// Read-only access to ECB conversion audit evidence.
|
||||
///
|
||||
/// This service exists for manual visual verification. It exposes conversions
|
||||
/// already recorded by backend posting workflows and never recalculates money.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EcbServiceClient<T> {
|
||||
inner: tonic::client::Grpc<T>,
|
||||
}
|
||||
impl EcbServiceClient<tonic::transport::Channel> {
|
||||
/// Attempt to create a new client by connecting to a given endpoint.
|
||||
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> EcbServiceClient<T>
|
||||
where
|
||||
T: tonic::client::GrpcService<tonic::body::Body>,
|
||||
T::Error: Into<StdError>,
|
||||
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
||||
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::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,
|
||||
) -> EcbServiceClient<InterceptedService<T, F>>
|
||||
where
|
||||
F: tonic::service::Interceptor,
|
||||
T::ResponseBody: Default,
|
||||
T: tonic::codegen::Service<
|
||||
http::Request<tonic::body::Body>,
|
||||
Response = http::Response<
|
||||
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
|
||||
>,
|
||||
>,
|
||||
<T as tonic::codegen::Service<
|
||||
http::Request<tonic::body::Body>,
|
||||
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||
{
|
||||
EcbServiceClient::new(InterceptedService::new(inner, interceptor))
|
||||
}
|
||||
/// Compress requests with the given encoding.
|
||||
///
|
||||
/// This requires the server to support it otherwise it might respond with an
|
||||
/// error.
|
||||
#[must_use]
|
||||
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.send_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Enable decompressing responses.
|
||||
#[must_use]
|
||||
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.accept_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of a decoded message.
|
||||
///
|
||||
/// Default: `4MB`
|
||||
#[must_use]
|
||||
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_decoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of an encoded message.
|
||||
///
|
||||
/// Default: `usize::MAX`
|
||||
#[must_use]
|
||||
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_encoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// List immutable ECB conversion evidence for one money value.
|
||||
pub async fn list_ecb_conversion_evidence(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ListEcbConversionEvidenceRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListEcbConversionEvidenceResponse>,
|
||||
tonic::Status,
|
||||
> {
|
||||
self.inner
|
||||
.ready()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tonic::Status::unknown(
|
||||
format!("Service was not ready: {}", e.into()),
|
||||
)
|
||||
})?;
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static(
|
||||
"/komp_ac.ecb.EcbService/ListEcbConversionEvidence",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new(
|
||||
"komp_ac.ecb.EcbService",
|
||||
"ListEcbConversionEvidence",
|
||||
),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Generated server implementations.
|
||||
pub mod ecb_service_server {
|
||||
#![allow(
|
||||
unused_variables,
|
||||
dead_code,
|
||||
missing_docs,
|
||||
clippy::wildcard_imports,
|
||||
clippy::let_unit_value,
|
||||
)]
|
||||
use tonic::codegen::*;
|
||||
/// Generated trait containing gRPC methods that should be implemented for use with EcbServiceServer.
|
||||
#[async_trait]
|
||||
pub trait EcbService: std::marker::Send + std::marker::Sync + 'static {
|
||||
/// List immutable ECB conversion evidence for one money value.
|
||||
async fn list_ecb_conversion_evidence(
|
||||
&self,
|
||||
request: tonic::Request<super::ListEcbConversionEvidenceRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ListEcbConversionEvidenceResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
}
|
||||
/// Read-only access to ECB conversion audit evidence.
|
||||
///
|
||||
/// This service exists for manual visual verification. It exposes conversions
|
||||
/// already recorded by backend posting workflows and never recalculates money.
|
||||
#[derive(Debug)]
|
||||
pub struct EcbServiceServer<T> {
|
||||
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> EcbServiceServer<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)
|
||||
}
|
||||
/// Enable decompressing requests with the given encoding.
|
||||
#[must_use]
|
||||
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.accept_compression_encodings.enable(encoding);
|
||||
self
|
||||
}
|
||||
/// Compress responses with the given encoding, if the client supports it.
|
||||
#[must_use]
|
||||
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.send_compression_encodings.enable(encoding);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of a decoded message.
|
||||
///
|
||||
/// Default: `4MB`
|
||||
#[must_use]
|
||||
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.max_decoding_message_size = Some(limit);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of an encoded message.
|
||||
///
|
||||
/// Default: `usize::MAX`
|
||||
#[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 EcbServiceServer<T>
|
||||
where
|
||||
T: EcbService,
|
||||
B: Body + std::marker::Send + 'static,
|
||||
B::Error: Into<StdError> + std::marker::Send + 'static,
|
||||
{
|
||||
type Response = http::Response<tonic::body::Body>;
|
||||
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() {
|
||||
"/komp_ac.ecb.EcbService/ListEcbConversionEvidence" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct ListEcbConversionEvidenceSvc<T: EcbService>(pub Arc<T>);
|
||||
impl<
|
||||
T: EcbService,
|
||||
> tonic::server::UnaryService<
|
||||
super::ListEcbConversionEvidenceRequest,
|
||||
> for ListEcbConversionEvidenceSvc<T> {
|
||||
type Response = super::ListEcbConversionEvidenceResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<
|
||||
super::ListEcbConversionEvidenceRequest,
|
||||
>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as EcbService>::list_ecb_conversion_evidence(
|
||||
&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 = ListEcbConversionEvidenceSvc(inner);
|
||||
let codec = tonic_prost::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 {
|
||||
let mut response = http::Response::new(
|
||||
tonic::body::Body::default(),
|
||||
);
|
||||
let headers = response.headers_mut();
|
||||
headers
|
||||
.insert(
|
||||
tonic::Status::GRPC_STATUS,
|
||||
(tonic::Code::Unimplemented as i32).into(),
|
||||
);
|
||||
headers
|
||||
.insert(
|
||||
http::header::CONTENT_TYPE,
|
||||
tonic::metadata::GRPC_CONTENT_TYPE,
|
||||
);
|
||||
Ok(response)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<T> Clone for EcbServiceServer<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,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Generated gRPC service name
|
||||
pub const SERVICE_NAME: &str = "komp_ac.ecb.EcbService";
|
||||
impl<T> tonic::server::NamedService for EcbServiceServer<T> {
|
||||
const NAME: &'static str = SERVICE_NAME;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user