pub struct Session<E> { /* private fields */ }Expand description
What a connection is served with, as a Resolver builds it.
Implementations§
Source§impl<E> Session<E>
impl<E> Session<E>
Sourcepub fn tenant(self, tenant: impl Into<String>) -> Result<Self, TenantError>
pub fn tenant(self, tenant: impl Into<String>) -> Result<Self, TenantError>
Serves the connection in tenant alone, whatever tenant its requests
name: reads and loads see only tenant’s events, writes land in
tenant, and the version, routing-key and snapshot lookups are
tenant’s. A host that maps a client’s credential to a tenant in its
Resolver confines the client this way, over one store shared by
every tenant.
The client sees a store of its own: the events it reads come back in
the default tenant (""), so it names no tenant anywhere — its
projections, snapshots and cursors are kept as against a store of a
single tenant.
Requests that would reach past the tenant are refused: replicate,
which keeps the caller’s timestamps (an event backdated behind the
cursor of a subscription over the shared store would never reach it),
and the subscriber calls, since a subscriber row belongs to no tenant.
A tenant’s application keeps its subscriptions in a store of its own:
a Sidecar (evento-core’s rw feature) with the client as its events
source.
§Errors
TenantError for "" — the default tenant, which a session serving
no tenant reaches along with every other — or for a tenant id longer
than a store keeps.
Sourcepub fn keep(self, guard: impl Any + Send + Sync) -> Self
pub fn keep(self, guard: impl Any + Send + Sync) -> Self
Keeps guard alive until the connection ends, then drops it. A host
leases a tenant to the connection this way: the lease is released when
the client goes away, whatever the reason.
Sourcepub fn close_when(self, signal: Receiver<bool>) -> Self
pub fn close_when(self, signal: Receiver<bool>) -> Self
Ends the connection from the server’s side when signal turns true
(a credential was revoked). In-flight requests fail at the client, and
its reconnect goes through the resolver again, which can now refuse it.