Skip to main content

CascadeRunner

Struct CascadeRunner 

Source
pub struct CascadeRunner { /* private fields */ }
Expand description

Builder-pattern runner for the streaming engine.

Handles all parallel fetching, retry-forever logic, plugin dispatch, cursor management, and graceful shutdown.

§Example

use quicknode_cascade::{CascadeRunner, solana};

struct Logger;
impl solana::Plugin for Logger {
    fn name(&self) -> &'static str { "logger" }
    fn on_block<'a>(&'a self, block: &'a solana::BlockData) -> solana::PluginFuture<'a> {
        Box::pin(async move {
            println!("slot {}", block.slot);
            Ok(())
        })
    }
}

CascadeRunner::solana_mainnet()
    .auth_token("your-jwt-token")
    .backfill(400_000_000, 400_000_010)
    .with_plugin(Box::new(Logger))
    .run()
    .expect("done");

Implementations§

Source§

impl CascadeRunner

Source

pub fn solana_mainnet() -> Self

Create a runner for Solana mainnet via QuickNode Cascade.

Source

pub fn solana_devnet() -> Self

Create a runner for Solana devnet via QuickNode Cascade.

Source

pub fn chain(name: &str) -> Self

Create a runner for a named chain.

The chain name maps to the Cascade endpoint: https://{chain}-cascade.quiknode.io

§Examples
use quicknode_cascade::CascadeRunner;

// These are equivalent:
let a = CascadeRunner::solana_mainnet();
let b = CascadeRunner::chain("solana-mainnet");
Source

pub fn auth_token(self, token: &str) -> Self

Set the authentication token (JWT) for the Cascade endpoint.

The token is sent as Authorization: Bearer <token> on every request.

Source

pub fn source_url(self, url: &str) -> Self

Override the source URL directly (for custom RPC endpoints).

Use this when pointing at your own Solana validator or a non-Cascade RPC.

Source

pub fn with_plugin(self, plugin: Box<dyn Plugin>) -> Self

Register a plugin. Multiple plugins can be registered; each sees all events.

Source

pub fn concurrency(self, n: usize) -> Self

Set parallel fetch concurrency (default: 10).

Source

pub fn encoding(self, encoding: &str) -> Self

Set the encoding for fetching blocks (default: “json”).

on_slot fires for ALL encodings with the raw JSON.

In "json" mode, the runner additionally extracts structured data and calls on_block/on_transaction/on_token_transfer/on_account_activity.

In any other mode ("jsonParsed", "base64", etc.), only on_slot fires.

Source

pub fn backfill(self, start: u64, end: u64) -> Self

Set the runner to backfill a specific slot range.

Source

pub fn live(self) -> Self

Set the runner to follow the chain tip in real-time.

Source

pub fn live_from(self, slot: u64) -> Self

Set the runner to follow the chain tip, starting from a specific slot.

Source

pub fn cursor_file(self, path: &str) -> Self

Set the cursor file path for resume support (default: “cursor.json”).

Source

pub fn tip_buffer(self, slots: u64) -> Self

Set the tip buffer for live mode (default: 100 slots).

Keeps the client N slots behind the chain tip to ensure data availability on Cascade. Set to 0 for direct RPC endpoints.

Source

pub fn run(self) -> Result<()>

Run the engine. Blocks until completion (backfill) or shutdown signal (live).

Creates a tokio runtime internally. If called from within an async context, use run_async instead.

Source

pub async fn run_async(self) -> Result<()>

Async version of run.

Use this from within an existing tokio runtime.

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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