pub struct RelayServiceClient<T> { /* private fields */ }Expand description
A relay (kernable relay, or kernable Cloud’s): it keeps copies of writers’ records outside
their networks, and readers follow a copy there. It holds the records only; it applies none. A
pusher beside the writer (kernable push) follows the writer as a reader does and sends what it
gets on, over a connection it opens itself, so the writer accepts none from outside. Readers
follow a copy as they follow a writer (ReplicationService.Follow, reader, copy), and check
every record against the writer’s checkpoints as they always do: a relay can withhold records,
never change one.
What reaches a relay is sealed with the copy key, which the pusher and the copy’s readers hold and the relay does not: each record (ReplicatedRecord.sealed), each record batch’s vault values and files (RecordBatch.sealed), each image batch (ImageBatch.sealed) and the image’s length (ImageEnd.sealed). A relay sees records’ positions, hashes and sizes, nothing else. A sealed value is the key’s ID (the first 8 bytes of its SHA-256), a random 24-byte nonce and the XChaCha20-Poly1305 ciphertext, its associated data a label of what it is and where it belongs (see the kernel’s src/seal.rs), so a relay cannot move one elsewhere unnoticed. Every stream at a relay (Push, Calls, and Follow of ReplicationService) names its key and copy in its request, signed, so the relay refuses a stranger before it reads any message: headers kernable-relay-key (key ID), kernable-relay-copy, kernable-relay-at (ms since the epoch, within 60 s of the relay’s clock) and kernable-relay-sig (hex, Ed25519 by that key over the message “kernable.v1.relay-stream” | rpc (“push”, “calls”, “follow”) | copy | key ID | at, laid out as in SIGNING.md). The stream’s hello must name the same key and copy; the challenge follows as before.
Implementations§
Source§impl<T> RelayServiceClient<T>where
T: GrpcService<Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
impl<T> RelayServiceClient<T>where
T: GrpcService<Body>,
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
pub fn with_origin(inner: T, origin: Uri) -> Self
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> RelayServiceClient<InterceptedService<T, F>>where
F: Interceptor,
T::ResponseBody: Default,
T: Service<Request<Body>, Response = Response<<T as GrpcService<Body>>::ResponseBody>>,
<T as Service<Request<Body>>>::Error: Into<StdError> + Send + Sync,
Sourcepub fn send_compressed(self, encoding: CompressionEncoding) -> Self
pub fn send_compressed(self, encoding: CompressionEncoding) -> Self
Compress requests with the given encoding.
This requires the server to support it otherwise it might respond with an error.
Sourcepub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
Enable decompressing responses.
Sourcepub fn max_decoding_message_size(self, limit: usize) -> Self
pub fn max_decoding_message_size(self, limit: usize) -> Self
Limits the maximum size of a decoded message.
Default: 4MB
Sourcepub fn max_encoding_message_size(self, limit: usize) -> Self
pub fn max_encoding_message_size(self, limit: usize) -> Self
Limits the maximum size of an encoded message.
Default: usize::MAX
Sourcepub async fn push(
&mut self,
request: impl IntoStreamingRequest<Message = PushRequest>,
) -> Result<Response<Streaming<PushResponse>>, Status>
pub async fn push( &mut self, request: impl IntoStreamingRequest<Message = PushRequest>, ) -> Result<Response<Streaming<PushResponse>>, Status>
PushRequest.hello -> PushResponse.challenge -> PushRequest.challenge_response -> PushResponse.start (where the copy stands), then the writer’s records from there: an image (image…, image_end) when the copy is empty or the writer no longer keeps its next record, then record batches. An image_end without an image empties the copy (the writer’s log no longer continues it, and its pusher was told to start the copy anew): the records from 1 follow. Record batches without records only say where the writer stands. The relay acknowledges what it wrote and synced.
Sourcepub async fn calls(
&mut self,
request: impl IntoStreamingRequest<Message = CallsRequest>,
) -> Result<Response<Streaming<CallsResponse>>, Status>
pub async fn calls( &mut self, request: impl IntoStreamingRequest<Message = CallsRequest>, ) -> Result<Response<Streaming<CallsResponse>>, Status>
Opened by the pusher beside its push (hello and challenge as for Push): the writes readers of the copy sent the relay come down it, and the writer’s answers go back up, sealed both ways.
Sourcepub async fn call(
&mut self,
request: impl IntoRequest<SealedCall>,
) -> Result<Response<SealedReply>, Status>
pub async fn call( &mut self, request: impl IntoRequest<SealedCall>, ) -> Result<Response<SealedReply>, Status>
A reader of a copy: a write for the writer (a command, a file, a cache value, …), sealed, answered with the writer’s answer, sealed. The relay passes it to the copy’s pusher, which makes the call on the writer; UNAVAILABLE while no pusher is connected.
Sourcepub async fn copy_key(
&mut self,
request: impl IntoRequest<CopyKeyRequest>,
) -> Result<Response<CopyKeyReply>, Status>
pub async fn copy_key( &mut self, request: impl IntoRequest<CopyKeyRequest>, ) -> Result<Response<CopyKeyReply>, Status>
A new instance of a copy asks for the copy key (design/instance-keys.md). The relay lets
only a key it lets read the copy ask, and passes the ask to the copy’s pusher. The pusher
seals the key to the asking key if its grant, signed by a root the pusher trusts, allows
copy for this copy, and neither the key nor its grant’s signer is revoked; it signs what it
sends. The relay carries it and never sees the key.
Trait Implementations§
Source§impl<T: Clone> Clone for RelayServiceClient<T>
impl<T: Clone> Clone for RelayServiceClient<T>
Auto Trait Implementations§
impl<T> !Freeze for RelayServiceClient<T>
impl<T> Forget for RelayServiceClient<T>
impl<T> Move for RelayServiceClient<T>
impl<T> RefUnwindSafe for RelayServiceClient<T>where
Grpc<T>: RefUnwindSafe,
impl<T> Send for RelayServiceClient<T>
impl<T> Sync for RelayServiceClient<T>
impl<T> Unpin for RelayServiceClient<T>
impl<T> UnsafeUnpin for RelayServiceClient<T>where
Grpc<T>: UnsafeUnpin,
impl<T> UnwindSafe for RelayServiceClient<T>where
Grpc<T>: UnwindSafe,
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request