pub struct P2mApiService<S, P, C, M> { /* private fields */ }
Expand description
P2M (Process-to-Middleware) API Service.
Central orchestrator for process-initiated traceability operations. This service manages the complete lifecycle of tracked I/O operations from initial resource enrollment through final completion reporting.
§Core Responsibilities
Resource Enrollment: Maintains registry of process file descriptors and their associated resources (files or network streams) for traceability tracking.
Flow Authorization: Coordinates with compliance and sequencer services to evaluate whether requested I/O operations should be permitted based on current policies.
Distributed Coordination: Communicates with remote middleware instances for cross-node flows, ensuring consistent policy enforcement across the network.
Provenance Tracking: Updates provenance records following successful operations to maintain complete audit trails for compliance and governance.
§Concurrency and State Management
Uses concurrent data structures (DashMap
) to handle multiple simultaneous requests
from different processes while maintaining consistency. Resource and flow maps are
shared across service instances using Arc
for efficient cloning.
§Generic Type Parameters
S
: Sequencer service for flow coordination and resource reservationsP
: Provenance service for provenance trackingC
: Compliance service for policy evaluation and authorization decisionsM
: M2M client service for communication with remote middleware instances
Implementations§
Source§impl<S, P, C, M> P2mApiService<S, P, C, M>
impl<S, P, C, M> P2mApiService<S, P, C, M>
Sourcepub fn new(sequencer: S, provenance: P, compliance: C, m2m: M) -> Self
pub fn new(sequencer: S, provenance: P, compliance: C, m2m: M) -> Self
Creates a new P2M API service with the provided component services.
Initializes empty resource and flow maps and stores references to the core services needed for traceability operations. The service is ready to handle process requests immediately after construction.
§Arguments
sequencer
- Service for flow coordination and resource reservationsprovenance
- Service for provenance trackingcompliance
- Service for policy evaluation and authorization decisionsm2m
- Client for communication with remote middleware instances
Sourcepub fn with_resource_validation(self, enable: bool) -> Self
pub fn with_resource_validation(self, enable: bool) -> Self
Enables or disables resource validation for incoming P2M requests.
When validation is enabled, all incoming requests are validated for:
- Valid process IDs (must correspond to running processes)
- Valid stream addresses (must be well-formed and compatible)
This method uses the same ResourceValidator logic as the Tower filter but integrates it directly into the service to avoid complex Send/Sync constraints with async runtimes.
§Arguments
enable
- Whether to enable resource validation
§Returns
Self with validation setting applied
Trait Implementations§
Source§impl<S: Clone, P: Clone, C: Clone, M: Clone> Clone for P2mApiService<S, P, C, M>
impl<S: Clone, P: Clone, C: Clone, M: Clone> Clone for P2mApiService<S, P, C, M>
Source§fn clone(&self) -> P2mApiService<S, P, C, M>
fn clone(&self) -> P2mApiService<S, P, C, M>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<S, P, C, M> Service<P2mRequest> for P2mApiService<S, P, C, M>where
S: Service<SequencerRequest, Response = SequencerResponse, Error = TraceabilityError> + Clone + Send + 'static,
S::Future: Send,
P: Service<ProvenanceRequest, Response = ProvenanceResponse, Error = TraceabilityError> + Clone + Send + NodeId + 'static,
P::Future: Send,
C: Service<ComplianceRequest, Response = ComplianceResponse, Error = TraceabilityError> + Clone + Send + 'static,
C::Future: Send,
M: Service<M2mRequest, Response = M2mResponse, Error = TraceabilityError> + Clone + Send + 'static,
M::Future: Send,
impl<S, P, C, M> Service<P2mRequest> for P2mApiService<S, P, C, M>where
S: Service<SequencerRequest, Response = SequencerResponse, Error = TraceabilityError> + Clone + Send + 'static,
S::Future: Send,
P: Service<ProvenanceRequest, Response = ProvenanceResponse, Error = TraceabilityError> + Clone + Send + NodeId + 'static,
P::Future: Send,
C: Service<ComplianceRequest, Response = ComplianceResponse, Error = TraceabilityError> + Clone + Send + 'static,
C::Future: Send,
M: Service<M2mRequest, Response = M2mResponse, Error = TraceabilityError> + Clone + Send + 'static,
M::Future: Send,
Source§type Response = P2mResponse
type Response = P2mResponse
Source§type Error = TraceabilityError
type Error = TraceabilityError
Source§type Future = Pin<Box<dyn Future<Output = Result<<P2mApiService<S, P, C, M> as Service<P2mRequest>>::Response, <P2mApiService<S, P, C, M> as Service<P2mRequest>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<P2mApiService<S, P, C, M> as Service<P2mRequest>>::Response, <P2mApiService<S, P, C, M> as Service<P2mRequest>>::Error>> + Send>>
Source§fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Poll::Ready(Ok(()))
when the service is able to process requests. Read moreSource§fn call(&mut self, request: P2mRequest) -> Self::Future
fn call(&mut self, request: P2mRequest) -> Self::Future
Auto Trait Implementations§
impl<S, P, C, M> Freeze for P2mApiService<S, P, C, M>
impl<S, P, C, M> !RefUnwindSafe for P2mApiService<S, P, C, M>
impl<S, P, C, M> Send for P2mApiService<S, P, C, M>
impl<S, P, C, M> Sync for P2mApiService<S, P, C, M>
impl<S, P, C, M> Unpin for P2mApiService<S, P, C, M>
impl<S, P, C, M> !UnwindSafe for P2mApiService<S, P, C, M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].§impl<T> Pointable for T
impl<T> Pointable for T
§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService
, that is a [Service
] whose
response is another service. Read more§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
HandleError
, that will handle errors
by converting them into responses. Read more§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling it with the provided request once it is ready.§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready
method. Read more§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready
method. Read more§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready
method. Read more§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
§fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>where
Self: Sized,
F: Predicate<NewRequest>,
fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>where
Self: Sized,
F: Predicate<NewRequest>,
§fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
AsyncFilter
that conditionally accepts or
rejects requests based on an [async predicate]. Read more