Skip to main content

RelayServiceClient

Struct RelayServiceClient 

Source
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 RelayServiceClient<Channel>

Source

pub async fn connect<D>(dst: D) -> Result<Self, Error>
where D: TryInto<Endpoint>, D::Error: Into<StdError>,

Attempt to create a new client by connecting to a given endpoint.

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,

Source

pub fn new(inner: T) -> Self

Source

pub fn with_origin(inner: T, origin: Uri) -> Self

Source

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,

Source

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.

Source

pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self

Enable decompressing responses.

Source

pub fn max_decoding_message_size(self, limit: usize) -> Self

Limits the maximum size of a decoded message.

Default: 4MB

Source

pub fn max_encoding_message_size(self, limit: usize) -> Self

Limits the maximum size of an encoded message.

Default: usize::MAX

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for RelayServiceClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where Grpc<T>: Send,

§

impl<T> Sync for RelayServiceClient<T>
where Grpc<T>: Sync,

§

impl<T> Unpin for RelayServiceClient<T>
where Grpc<T>: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more