pub struct PubSubEventClientBuilder { /* private fields */ }
Expand description
A builder for creating a new PubSubEventClient
use tokio::sync::mpsc;
use switchboard_solana::{ FunctionVerifyEvent, *SWITCHBOARD_ATTESTATION_PROGRAM_ID };
let (fn_verify_sender, mut fn_verify_recv) = tokio::sync::mpsc::unbounded_channel::<FunctionVerifyEvent>();
let event_watcher = pubsub::PubSubEventClientBuilder::new(*SWITCHBOARD_ATTESTATION_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 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