ModuleHost

Struct ModuleHost 

Source
pub struct ModuleHost {
    pub info: Arc<ModuleInfo>,
    /* private fields */
}

Fields§

§info: Arc<ModuleInfo>

Implementations§

Source§

impl ModuleHost

Source

pub fn info(&self) -> &ModuleInfo

Source

pub fn subscriptions(&self) -> &ModuleSubscriptions

Source

pub async fn on_module_thread<F, R>( &self, label: &str, f: F, ) -> Result<R, Error>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Run a function on the JobThread for this module. This would deadlock if it is called within another call to on_module_thread. Since this is async, and f is sync, deadlocking shouldn’t be a problem.

Source

pub async fn disconnect_client(&self, client_id: ClientActorId)

Source

pub async fn call_identity_connected( &self, caller_identity: Identity, caller_connection_id: ConnectionId, ) -> Result<(), ClientConnectedError>

Invoke the module’s client_connected reducer, if it has one, and insert a new row into st_client for (caller_identity, caller_connection_id).

The host inspects st_client when restarting in order to run client_disconnected reducers for clients that were connected at the time when the host went down. This ensures that every client connection eventually has client_disconnected invoked.

If this method returns Ok, then the client connection has been approved, and the new row has been inserted into st_client.

If this method returns Err, then the client connection has either failed or been rejected, and st_client has not been modified. In this case, the caller should terminate the connection.

Source

pub fn call_identity_disconnected_inner( &self, caller_identity: Identity, caller_connection_id: ConnectionId, inst: &mut dyn ModuleInstance, ) -> Result<(), ReducerCallError>

Source

pub async fn call_identity_disconnected( &self, caller_identity: Identity, caller_connection_id: ConnectionId, ) -> Result<(), ReducerCallError>

Invoke the module’s client_disconnected reducer, if it has one, and delete the client’s row from st_client, if any.

The host inspects st_client when restarting in order to run client_disconnected reducers for clients that were connected at the time when the host went down. This ensures that every client connection eventually has client_disconnected invoked.

Unlike Self::call_identity_connected, this method swallows errors returned by the client_disconnected reducer. The database can’t reject a disconnection - the client’s gone, whether the database likes it or not.

If this method returns an error, the database is likely to wind up in a bad state, as that means we’ve somehow failed to delete from st_client. We cannot meaningfully handle this. Sometimes it just means that the database no longer exists, though, which is fine.

Source

pub async fn call_reducer( &self, caller_identity: Identity, caller_connection_id: Option<ConnectionId>, client: Option<Arc<ClientConnectionSender>>, request_id: Option<RequestId>, timer: Option<Instant>, reducer_name: &str, args: ReducerArgs, ) -> Result<ReducerCallResult, ReducerCallError>

Source

pub async fn call_scheduled_reducer( &self, call_reducer_params: impl FnOnce(&MutTxId) -> Result<Option<CallReducerParams>> + Send + 'static, ) -> Result<ReducerCallResult, ReducerCallError>

Source

pub fn subscribe_to_logs(&self) -> Result<Receiver<Bytes>>

Source

pub async fn init_database( &self, program: Program, ) -> Result<Option<ReducerCallResult>, InitDatabaseError>

Source

pub async fn update_database( &self, program: Program, old_module_info: Arc<ModuleInfo>, ) -> Result<UpdateDatabaseResult, Error>

Source

pub async fn exit(&self)

Source

pub async fn exited(&self)

Source

pub fn inject_logs(&self, log_level: LogLevel, message: &str)

Source

pub async fn one_off_query<F: WebsocketFormat>( &self, caller_identity: Identity, query: String, client: Arc<ClientConnectionSender>, message_id: Vec<u8>, timer: Instant, into_message: impl FnOnce(OneOffQueryResponseMessage<F>) -> SerializableMessage + Send + 'static, ) -> Result<(), Error>

Execute a one-off query and send the results to the given client. This only returns an error if there is a db-level problem. An error with the query itself will be sent to the client.

Source

pub fn clear_table(&self, table_name: &str) -> Result<(), Error>

FIXME(jgilles): this is a temporary workaround for deleting not currently being supported for tables without primary keys. It is only used in the benchmarks. Note: this doesn’t drop the table, it just clears it!

Source

pub fn downgrade(&self) -> WeakModuleHost

Source

pub fn database_info(&self) -> &Database

Trait Implementations§

Source§

impl Clone for ModuleHost

Source§

fn clone(&self) -> ModuleHost

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ModuleHost

Source§

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

Formats the value using the given formatter. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T