Struct astro_run_server::AstroRunServer
source · pub struct AstroRunServer { /* private fields */ }
Implementations§
source§impl AstroRunServer
impl AstroRunServer
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/server.rs (line 6)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
async fn main() -> Result<()> {
let server = AstroRunServer::new();
// Start server in background
let handle = tokio::spawn({
let server = server.clone();
async move {
server.serve("127.0.0.1:5338").await.unwrap();
}
});
let astro_run = AstroRun::builder().runner(server).build();
let workflow = r#"
jobs:
test:
name: Test Job
steps:
- timeout: 60m
continue-on-error: false
run: Hello World
"#;
let workflow = Workflow::builder()
.config(workflow)
.build(&astro_run)
.unwrap();
let ctx = astro_run.execution_context().build();
// Run workflow
let _res = workflow.run(ctx).await;
// Wait for server to stop
handle.await.unwrap();
Ok(())
}
pub fn with_scheduler<T>(scheduler: T) -> Selfwhere
T: Scheduler + 'static,
sourcepub async fn serve(self, url: impl Into<&str>) -> Result<()>
pub async fn serve(self, url: impl Into<&str>) -> Result<()>
Examples found in repository?
examples/server.rs (line 13)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
async fn main() -> Result<()> {
let server = AstroRunServer::new();
// Start server in background
let handle = tokio::spawn({
let server = server.clone();
async move {
server.serve("127.0.0.1:5338").await.unwrap();
}
});
let astro_run = AstroRun::builder().runner(server).build();
let workflow = r#"
jobs:
test:
name: Test Job
steps:
- timeout: 60m
continue-on-error: false
run: Hello World
"#;
let workflow = Workflow::builder()
.config(workflow)
.build(&astro_run)
.unwrap();
let ctx = astro_run.execution_context().build();
// Run workflow
let _res = workflow.run(ctx).await;
// Wait for server to stop
handle.await.unwrap();
Ok(())
}
Trait Implementations§
source§impl AstroRunService for AstroRunServer
impl AstroRunService for AstroRunServer
§type SubscribeEventsStream = ReceiverStream<Result<Event, Status>>
type SubscribeEventsStream = ReceiverStream<Result<Event, Status>>
Server streaming response type for the SubscribeEvents method.
fn subscribe_events<'life0, 'async_trait>(
&'life0 self,
request: Request<RunnerMetadata>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::SubscribeEventsStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn report_log<'life0, 'async_trait>(
&'life0 self,
request: Request<WorkflowLog>
) -> Pin<Box<dyn Future<Output = Result<Response<ReportLogResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn report_run_completed<'life0, 'async_trait>(
&'life0 self,
request: Request<ReportRunCompletedRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ReportRunCompletedResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl Clone for AstroRunServer
impl Clone for AstroRunServer
source§fn clone(&self) -> AstroRunServer
fn clone(&self) -> AstroRunServer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Runner for AstroRunServer
impl Runner for AstroRunServer
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: Context
) -> Pin<Box<dyn Future<Output = RunResponse> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_step_completed(&self, result: StepRunResult)
fn on_job_completed(&self, result: JobRunResult)
fn on_workflow_completed(&self, result: WorkflowRunResult)
fn on_run_step(&self, event: RunStepEvent)
fn on_run_job(&self, event: RunJobEvent)
fn on_run_workflow(&self, event: RunWorkflowEvent)
fn on_log(&self, log: WorkflowLog)
fn on_state_change(&self, event: WorkflowStateEvent)
Auto Trait Implementations§
impl !RefUnwindSafe for AstroRunServer
impl Send for AstroRunServer
impl Sync for AstroRunServer
impl Unpin for AstroRunServer
impl !UnwindSafe for AstroRunServer
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
Mutably borrows from an owned value. Read more
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>
Wrap the input message
T
in a tonic::Request