pub struct Host { /* private fields */ }Expand description
The host for one run.
Implementations§
Source§impl Host
impl Host
Sourcepub fn context(&self) -> Result<Context>
pub fn context(&self) -> Result<Context>
The run’s context: schedule, run, rule set, source, pipeline, last success, options.
Sourcepub fn context_json(&self) -> Result<Json>
pub fn context_json(&self) -> Result<Json>
The context as the host sent it.
Sourcepub fn store_raw(
&self,
name: &str,
format: &str,
bytes: &[u8],
) -> Result<String>
pub fn store_raw( &self, name: &str, format: &str, bytes: &[u8], ) -> Result<String>
Store one raw item (kept byte for byte, never parsed) in the run’s source; returns
its id. format is a hint for the pipeline: csv, json, ndjson, text, bytes.
Sourcepub fn run_ruleset(&self, ruleset_id: Option<&str>) -> Result<RulesetRun>
pub fn run_ruleset(&self, ruleset_id: Option<&str>) -> Result<RulesetRun>
Record connector.run and run a rule set (None: the schedule’s).
Sourcepub fn fetch(&self, req: &Request) -> Result<Response>
pub fn fetch(&self, req: &Request) -> Result<Response>
HTTP through the host’s client (its user agent, timeouts and retries).
Source§impl Host
impl Host
Sourcepub unsafe fn from_raw(raw: *const WnHost) -> Result<Host>
pub unsafe fn from_raw(raw: *const WnHost) -> Result<Host>
§Safety
raw must be the host table passed to weirdnet_plugin_run, valid for the run.
Sourcepub fn call(&self, method: &str, request: &Json) -> Result<Json>
pub fn call(&self, method: &str, request: &Json) -> Result<Json>
Call a host method with a JSON request.
Sourcepub fn input(&self) -> Result<Frame>
pub fn input(&self) -> Result<Frame>
Records as the code space’s input says (model, filters, grouping, sorting).
Sourcepub fn input_json(&self) -> Result<Json>
pub fn input_json(&self) -> Result<Json>
The input as the host sent it (a frame’s JSON), to hand on to Host::call_code.
Sourcepub fn call_code(&self, alias: &str, input: Option<&Json>) -> Result<Frame>
pub fn call_code(&self, alias: &str, input: Option<&Json>) -> Result<Frame>
A code space’s main calls a member by its alias (declared in an
@imports alias header) over input (a frame’s JSON; None: the member’s own default
input). Returns the member’s output frame. Only main may call.
Sourcepub fn call_space(&self, name: &str, input: Option<&Json>) -> Result<Frame>
pub fn call_space(&self, name: &str, input: Option<&Json>) -> Result<Frame>
A code space’s main runs another space (its main), declared as
@imports space:NAME. Returns its output frame. Spaces nest at most 8 deep, no loops.
Sourcepub fn inputs(&self) -> Result<Vec<String>>
pub fn inputs(&self) -> Result<Vec<String>>
The names of the inputs, when several feed this run (a pipeline’s fan-in).
Sourcepub fn input_named(&self, name: &str) -> Result<Frame>
pub fn input_named(&self, name: &str) -> Result<Frame>
One input by name (a pipeline’s fan-in: the upstream node’s id, or the edge’s name).
Sourcepub fn options(&self) -> Vec<(String, String)>
pub fn options(&self) -> Vec<(String, String)>
The step’s options, as text: code:to-bars?symbol=BTC/USDT&duration=5m gives
[("symbol", "BTC/USDT"), ("duration", "5m")]. Empty when none were given (or the
host is older than options).
Sourcepub fn input_request(&self) -> Result<Json>
pub fn input_request(&self) -> Result<Json>
The code space’s input request itself (what Host::input loads).
Sourcepub fn models(&self) -> Result<Json>
pub fn models(&self) -> Result<Json>
Every model with its fields: [{"name": "signals", "version": 2, "fields": [{"name", "type", "ref"}]}].
Sourcepub fn update(&self, model: &str, id: &str, values: Json) -> Result<()>
pub fn update(&self, model: &str, id: &str, values: Json) -> Result<()>
Change one record by id: values is an object of FIELD: VALUE.
Sourcepub fn update_where(
&self,
model: &str,
conditions: &[&str],
values: Json,
) -> Result<usize>
pub fn update_where( &self, model: &str, conditions: &[&str], values: Json, ) -> Result<usize>
Change every record matching all conditions (price > 3); returns how many.
Sourcepub fn update_each(
&self,
model: &str,
updates: Vec<(String, Json)>,
) -> Result<usize>
pub fn update_each( &self, model: &str, updates: Vec<(String, Json)>, ) -> Result<usize>
Change many records, each by id with its own values (one history entry).
Sourcepub fn create(&self, model: &str, values: Json) -> Result<String>
pub fn create(&self, model: &str, values: Json) -> Result<String>
Create a record; returns its id.
Sourcepub fn create_many(
&self,
model: &str,
records: Vec<Json>,
) -> Result<Vec<String>>
pub fn create_many( &self, model: &str, records: Vec<Json>, ) -> Result<Vec<String>>
Create many records (one history entry); returns their ids.