Skip to content

core.flows #

fn new #

fn new(args CoordinatorArgs) !Coordinator

enum StepStatus #

enum StepStatus {
	pending
	running
	success
	error
	skipped
}

struct Coordinator #

@[heap]
struct Coordinator {
pub mut:
	name         string
	current_step string // links to steps dict
	steps        map[string]&Step
	logger       logger.Logger
	ai           ?aiclient.AIClient
	redis        ?&redisclient.Redis
}

fn (Coordinator) clear_redis #

fn (c Coordinator) clear_redis() !

fn (Coordinator) get_all_steps_state #

fn (c Coordinator) get_all_steps_state() ![]map[string]string

Get all steps state from redis (for UI dashboard)

fn (Coordinator) get_step_state #

fn (c Coordinator) get_step_state(step_name string) !map[string]string

Get step state from redis

fn (Coordinator) run #

fn (mut c Coordinator) run() !

Run the entire flow starting from current_step

fn (Coordinator) run_step #

fn (mut c Coordinator) run_step(mut step Step) !

Run a single step, including error and next steps

fn (Coordinator) step_current #

fn (mut c Coordinator) step_current() !&Step

fn (Coordinator) step_new #

fn (mut c Coordinator) step_new(args StepNewArgs) !&Step

add step to it

struct CoordinatorArgs #

@[params]
struct CoordinatorArgs {
pub mut:
	name  string @[required]
	redis ?&redisclient.Redis
	ai    ?aiclient.AIClient = none
}

struct Step #

struct Step {
pub mut:
	status      StepStatus = .pending
	started_at  i64 // Unix timestamp
	finished_at i64
	error_msg   string
	name        string
	description string
	main_step   fn (mut s Step) ! @[required]
	context     map[string]string
	error_steps []string
	next_steps  []string
	error       string
	logs        []logger.LogItem
	params      paramsparser.Params
	coordinator &Coordinator
}

fn (Step) error_step_add #

fn (mut s Step) error_step_add(s2 &Step)

fn (Step) next_step_add #

fn (mut s Step) next_step_add(s2 &Step)

fn (Step) log #

fn (mut s Step) log(l logger.LogItemArgs) !

fn (Step) store_redis #

fn (mut s Step) store_redis() !

fn (Step) to_json #

fn (s Step) to_json() !string

struct StepJSON #

@[json: id]
struct StepJSON {
pub:
	name        string
	description string
	status      string
	error       string
	logs_count  int
	started_at  i64
	finished_at i64
	duration    i64 // milliseconds
}

struct StepNewArgs #

@[params]
struct StepNewArgs {
pub mut:
	name        string
	description string
	f           fn (mut s Step) ! @[required]
	context     map[string]string
	error_steps []string
	next_steps  []string
	error       string
	params      paramsparser.Params
}