Struct NeonSyncPeer
pub struct NeonSyncPeer<T> { /* private fields */ }event-store and sync only.Expand description
A SyncPeer over a NeonEventStore: one SQL request per pull and one
per push.
§Limits
new declares PeerLimits::minimum, which sits inside the
store’s own ceilings (NeonEventStore::MAX_EVENTS_PER_BATCH events and
NeonEventStore::MAX_EVENT_DATA_LEN bytes an event). A declaration above
those ceilings admits pushes the ingest then refuses, which is the failure
SY-18 exists to move ahead of the push. A pull reads up to one more group
than max_batch_events in one response, bounded by the store’s
max_response_bytes; a page of large groups that overflows it fails the
pull as NeonError::ResponseTooLarge, so declare limits whose page fits.
§Send
The bare SyncPeer only, as the store is bare-only: a wasm32
transport need not be Send. Bind it as SyncPeer in generic code
(constraint 4).
§Examples
use happenstance_neon::{NeonConfig, NeonEventStore, NeonSyncPeer, NullTransport};
use happenstance_neon::happenstance_sync::{PeerLimits, SyncPeer};
let store = NeonEventStore::new(NullTransport::new(), NeonConfig::default());
let peer = NeonSyncPeer::new(store);
assert_eq!(peer.limits(), PeerLimits::minimum());Implementations§
§impl<T> NeonSyncPeer<T>
impl<T> NeonSyncPeer<T>
pub const fn new(store: NeonEventStore<T>) -> Self
pub const fn new(store: NeonEventStore<T>) -> Self
A peer over store, declaring PeerLimits::minimum.
pub const fn with_limits(store: NeonEventStore<T>, limits: PeerLimits) -> Self
pub const fn with_limits(store: NeonEventStore<T>, limits: PeerLimits) -> Self
A peer over store that declares, and enforces, limits.
pub const fn store(&self) -> &NeonEventStore<T>
pub const fn store(&self) -> &NeonEventStore<T>
The store this peer reads and writes.
Trait Implementations§
§impl<T: Clone> Clone for NeonSyncPeer<T>
impl<T: Clone> Clone for NeonSyncPeer<T>
§impl<T: Debug> Debug for NeonSyncPeer<T>
impl<T: Debug> Debug for NeonSyncPeer<T>
§impl<T: SqlTransport> SyncPeer for NeonSyncPeer<T>
impl<T: SqlTransport> SyncPeer for NeonSyncPeer<T>
§async fn pull(
&self,
from: Option<&StoreResume>,
) -> Result<Pulled<StoreResume>, Self::Error>
async fn pull( &self, from: Option<&StoreResume>, ) -> Result<Pulled<StoreResume>, Self::Error>
Reads the store’s write groups above from, each whole, until the
declared budget is spent or the log ends, and names the store that
answered: one read-only request.
§Errors
NeonPeerError::Read for any failure of the request or of its
answer; nothing was forwarded, and the same pull can be retried.
§async fn push(&self, batch: &PushBatch) -> Result<Ack, Self::Error>
async fn push(&self, batch: &PushBatch) -> Result<Ack, Self::Error>
Ingests each pushed group as one atomic group with no compensation, and acknowledges with the watermark and the identity read in the same transaction: one request.
The travelling guards are not evaluated (SY-1): each is stored with its group and forwarded on pull (SY-30).
§Errors
NeonPeerError::EventTooLarge, TooManyEvents
or BatchTooLarge for a push the
declared limits do not admit, with nothing sent;
NeonPeerError::Ingest if the store refuses or fails the request,
which then wrote nothing, save the unknown outcome of a request that
got no answer (IngestError::Store); and NeonPeerError::Answer
if the request committed and its confirmation could not be read, in
which case re-delivery is a skip.