pub struct SourceQuery {
pub source_id: String,
pub query_id: String,
pub routes: Vec<OperationRoute>,
}Expand description
A specification for retrieving and transforming data from a source.
The SourceQuery struct defines where to obtain data and how to transform it
before processing. It specifies a data source, an identifier to query within
that source, and optionally a series of routing operations to apply to the
retrieved value.
This structure is a key component of signal definitions, allowing each signal to combine and transform data from multiple sources.
§Examples
use bothan_lib::registry::source::{SourceQuery, OperationRoute, Operation};
// Create a query for BTC/USDT from Binance, converted to USD
let query = SourceQuery::new(
"binance",
"btcusdt",
vec![
// Convert from USDT to USD using the USDT-USD signal
OperationRoute::new("USDT-USD", Operation::Multiply),
]
);Fields§
§source_id: StringThe identifier of the data source.
This corresponds to a registered worker that can provide data for this query. Examples might include exchange names like “binance” or “coinbase”.
query_id: StringThe query identifier to use within the data source.
This specifies what data to retrieve from the source, such as a trading pair like “btcusdt” or an asset identifier like “bitcoin”.
routes: Vec<OperationRoute>Routing operations to apply to the retrieved value.
These operations are applied sequentially to transform the source value before it is sent to the processor. If not provided, no transformations will be applied.
Implementations§
Source§impl SourceQuery
impl SourceQuery
Sourcepub fn new<T, U>(source_id: T, query_id: U, routes: Vec<OperationRoute>) -> Self
pub fn new<T, U>(source_id: T, query_id: U, routes: Vec<OperationRoute>) -> Self
Creates a new source query.
This constructor creates a source query that will retrieve data from the specified source and apply the provided routing operations.
§Examples
use bothan_lib::registry::source::{SourceQuery, OperationRoute, Operation};
// Create a query for ETH/USD from Coinbase with no transformations
let direct_query = SourceQuery::new("coinbase", "ETH-USD", vec![]);
// Create a query for ETH/BTC from Kraken, converted to USD
let converted_query = SourceQuery::new(
"kraken",
"ethbtc",
vec![
// Convert from BTC to USD using the BTC-USD signal
OperationRoute::new("BTC-USD", Operation::Multiply),
]
);Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for SourceQuery
impl<'__de, __Context> BorrowDecode<'__de, __Context> for SourceQuery
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl Clone for SourceQuery
impl Clone for SourceQuery
Source§fn clone(&self) -> SourceQuery
fn clone(&self) -> SourceQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SourceQuery
impl Debug for SourceQuery
Source§impl<__Context> Decode<__Context> for SourceQuery
impl<__Context> Decode<__Context> for SourceQuery
Source§impl<'de> Deserialize<'de> for SourceQuery
impl<'de> Deserialize<'de> for SourceQuery
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Encode for SourceQuery
impl Encode for SourceQuery
Source§impl PartialEq for SourceQuery
impl PartialEq for SourceQuery
Source§impl Serialize for SourceQuery
impl Serialize for SourceQuery
impl StructuralPartialEq for SourceQuery
Auto Trait Implementations§
impl Freeze for SourceQuery
impl RefUnwindSafe for SourceQuery
impl Send for SourceQuery
impl Sync for SourceQuery
impl Unpin for SourceQuery
impl UnwindSafe for SourceQuery
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request