stormchaser_model/runner.rs
1//! Models for workflow runner instances and step definitions.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7/// The connection status of a remote runner.
8#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type, PartialEq, Eq, schemars::JsonSchema)]
9#[sqlx(type_name = "runner_status", rename_all = "snake_case")]
10pub enum RunnerStatus {
11 /// The runner is currently online and communicating.
12 Online,
13 /// The runner has missed heartbeats and is considered offline.
14 Offline,
15}
16
17/// Represents a registered workflow runner instance.
18#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
19pub struct Runner {
20 /// Unique identifier for the runner.
21 pub id: String,
22 /// The type of runner environment.
23 pub runner_type: String, // e.g., "k8s", "binary", "ecs"
24 /// The current connection status of the runner.
25 pub status: RunnerStatus,
26 /// The protocol version the runner uses to communicate.
27 pub protocol_version: String,
28 /// A list of capabilities supported by the runner.
29 pub capabilities: Vec<String>,
30 /// Subject used to communicate with this specific runner.
31 pub nats_subject: String, // Subject used to communicate with this specific runner
32 /// Timestamp of the last received heartbeat.
33 pub last_heartbeat_at: DateTime<Utc>,
34 /// Timestamp when the runner first registered.
35 pub registered_at: DateTime<Utc>,
36}
37
38/// Defines a reusable workflow step implementation available on runners.
39#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
40pub struct StepDefinition {
41 /// Identifier for the step type (e.g., 'docker', 'wasm').
42 pub step_type: String,
43 /// JSON schema describing the required and optional parameters for this step.
44 pub schema: Value,
45 /// Optional documentation or description for the step type.
46 pub documentation: Option<String>,
47 /// Timestamp when this step definition was registered.
48 pub registered_at: DateTime<Utc>,
49}