Skip to main content

NeonSyncPeer

Struct NeonSyncPeer 

pub struct NeonSyncPeer<T> { /* private fields */ }
Available on crate features 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>

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

A peer over store that declares, and enforces, limits.

pub const fn store(&self) -> &NeonEventStore<T>

The store this peer reads and writes.

Trait Implementations§

§

impl<T: Clone> Clone for NeonSyncPeer<T>

§

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
§

impl<T: Debug> Debug for NeonSyncPeer<T>

§

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

Formats the value using the given formatter. Read more
§

impl<T: SqlTransport> SyncPeer for NeonSyncPeer<T>

§

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>

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.

§

type Error = NeonPeerError<<T as SqlTransport>::Error>

How this peer’s transport fails; each failure states its class. Read more
§

type Resume = StoreResume

Where to resume from: opaque to the caller, owned by the caller. Read more
§

fn limits(&self) -> PeerLimits

What this peer can accept, readable before a push rather than discovered as an error after one. Read more

Auto Trait Implementations§

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, 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> 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.