pub struct ScriptHandle<P> { /* private fields */ }Expand description
A typed handle for scheduling a script with specific parameters.
Created by the #[chronon::script] macro. The attribute turns the annotated
function into a handle factory (fn nightly_cleanup() -> ScriptHandle<…>) and
moves the body to an internal __*_impl entry point used by the executor.
Preferred scheduling: build jobs with Chronon’s fluent JobBuilder
(chronon_scheduler::JobBuilder, re-exported from the chronon / uf-chronon facade)
from this handle, then upsert via CoordinatorService or RemoteCoordinatorClient.
Self::job / Self::job_with_params only seed script_name / params_json — a
low-level alternate to the fluent builder.
§Examples
Handle identity (construction lives on Chronon JobBuilder — see
cargo run -p uf-chronon --example script_handle_job --features mem):
use chronon_core::ScriptHandle;
use serde::Serialize;
#[derive(Serialize)]
struct NightlyCleanupParams {
retention_days: u32,
}
let handle = ScriptHandle::<NightlyCleanupParams>::new("nightly_cleanup");
assert_eq!(handle.name(), "nightly_cleanup");Low-level seed (prefer JobBuilder::params in application code):
use chronon_core::{Job, ScriptHandle};
use serde::Serialize;
#[derive(Serialize)]
struct NightlyCleanupParams {
retention_days: u32,
}
let handle = ScriptHandle::<NightlyCleanupParams>::new("nightly_cleanup");
let job: Job = handle
.job_with_params(
"nightly-job",
&NightlyCleanupParams {
retention_days: 7,
},
)
.expect("params serialize");
assert_eq!(job.script_name, "nightly_cleanup");
assert_eq!(job.params_json["retention_days"], 7);Implementations§
Source§impl<P> ScriptHandle<P>
impl<P> ScriptHandle<P>
Sourcepub const fn new(name: &'static str) -> ScriptHandle<P>
pub const fn new(name: &'static str) -> ScriptHandle<P>
Create a new script handle (typically called by macro-generated code).
Source§impl<P> ScriptHandle<P>where
P: Serialize,
impl<P> ScriptHandle<P>where
P: Serialize,
Sourcepub fn job_with_params(
&self,
job_name: impl Into<String>,
params: &P,
) -> Result<Job, ChrononError>
pub fn job_with_params( &self, job_name: impl Into<String>, params: &P, ) -> Result<Job, ChrononError>
Baseline Job with typed params serialized into params_json.
Prefer Chronon JobBuilder::params for fluent construction.
Trait Implementations§
Source§impl<P> Clone for ScriptHandle<P>where
P: Clone,
impl<P> Clone for ScriptHandle<P>where
P: Clone,
Source§fn clone(&self) -> ScriptHandle<P>
fn clone(&self) -> ScriptHandle<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<P> Freeze for ScriptHandle<P>where
PhantomData<P>: Freeze,
impl<P> RefUnwindSafe for ScriptHandle<P>where
PhantomData<P>: RefUnwindSafe,
impl<P> Send for ScriptHandle<P>where
PhantomData<P>: Send,
impl<P> Sync for ScriptHandle<P>where
PhantomData<P>: Sync,
impl<P> Unpin for ScriptHandle<P>where
PhantomData<P>: Unpin,
impl<P> UnsafeUnpin for ScriptHandle<P>where
PhantomData<P>: UnsafeUnpin,
impl<P> UnwindSafe for ScriptHandle<P>where
PhantomData<P>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> 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> ⓘ
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> ⓘ
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