pub struct PubSubEventClientBuilder { /* private fields */ }Expand description
A builder for creating a new PubSubEventClient
use tokio::sync::mpsc;
use switchboard_solana::{ FunctionVerifyEvent, *SWITCHBOARD_ON_DEMAND_PROGRAM_ID };
let (fn_verify_sender, mut fn_verify_recv) = tokio::sync::mpsc::unbounded_channel::<FunctionVerifyEvent>();
let event_watcher = pubsub::PubSubEventClientBuilder::new(*SWITCHBOARD_ON_DEMAND_PROGRAM_ID, "https://api.mainnet-beta.solana.com".to_string())
.add_event_handler(fn_verify_sender);
let handler = tokio::spawn(async move {
loop {
tokio::select! {
Some(event) = fn_verify_recv.recv() => {
info!("[Rpc][Event] FunctionVerifyEvent - Function: {:?}", event.function);
}
}
}
});
tokio::select! {
_ = handler => {
info!("[Rpc] handler exited");
return Ok(());
}
_ = event_watcher.start() => {
info!("[Rpc] event_watcher exited");
return Ok(());
}
}Implementations§
source§impl PubSubEventClientBuilder
impl PubSubEventClientBuilder
pub fn new(program_id: Pubkey, websocket_url: String) -> Self
pub fn mentions(self, pubkey: Pubkey) -> Self
pub fn set_max_retries(self, max_retries: i32) -> Self
pub fn add_event_handler<E: Event + Send + Sync + 'static, S: EventSenderTrait<E> + 'static>( self, sender: S, ) -> PubSubEventClientWithHandlers
Auto Trait Implementations§
impl Freeze for PubSubEventClientBuilder
impl RefUnwindSafe for PubSubEventClientBuilder
impl Send for PubSubEventClientBuilder
impl Sync for PubSubEventClientBuilder
impl Unpin for PubSubEventClientBuilder
impl UnwindSafe for PubSubEventClientBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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