Skip to content

clients.daguclient #

a sal to work with dagu

Is a very nice task management system see https://dagu.readthedocs.io/

Example

import freeflowuniverse.crystallib.osal.dagu

mut z:=dagu.new()!

// name      string            @[required]
// cmd       string            @[required]
// cmd_file  bool  //if we wanna force to run it as a file which is given to bash -c  (not just a cmd in rclone)
// test      string
// test_file bool
// after     []string
// env       map[string]string
// oneshot   bool
p:=z.new(
    name:'test'
    cmd:'/bin/bash'
)!

fn configure #

fn configure(instance_ string) !

fn dag_new #

fn dag_new(args_ DAGArgs) DAG

create new DAG

name                 string // The name of the DAG, which is optional. The default name is the name of the file.
description          ?string // A brief description of the DAG.
tags                 ?string // Free tags that can be used to categorize DAGs, separated by commas.
env                  ?map[string]string // Environment variables that can be accessed by the DAG and its steps.
restart_wait_sec     ?int          // The number of seconds to wait after the DAG process stops before restarting it.
hist_retention_days  ?int          // The number of days to retain execution history (not for log files).
delay_sec            ?int          // The interval time in seconds between steps.
max_active_runs      ?int          // The maximum number of parallel running steps.
max_cleanup_time_sec ?int        // The maximum time to wait after sending a TERM signal to running steps before killing them.

fn get #

fn get(instance string, cfg Config) !DaguClient

fn heroplay #

fn heroplay(mut plbook playbook.PlayBook) !

fn (DaguClient) dag_new #

fn (mut client DaguClient) dag_new(args_ DAGArgs) DAG

create new DAG

name                 string // The name of the DAG, which is optional. The default name is the name of the file.
description          ?string // A brief description of the DAG.
tags                 ?string // Free tags that can be used to categorize DAGs, separated by commas.
env                  ?map[string]string // Environment variables that can be accessed by the DAG and its steps.
restart_wait_sec     ?int          // The number of seconds to wait after the DAG process stops before restarting it.
hist_retention_days  ?int          // The number of days to retain execution history (not for log files).
delay_sec            ?int          // The interval time in seconds between steps.
max_active_runs      ?int          // The maximum number of parallel running steps.
max_cleanup_time_sec ?int        // The maximum time to wait after sending a TERM signal to running steps before killing them.

fn (DaguClient) dag_register #

fn (mut client DaguClient) dag_register(dag DAG, opts NewDagOptions) !PostDagActionResponse

fn (DaguClient) dag_start #

fn (mut client DaguClient) dag_start(name string) !PostDagActionResponse

fn (DaguClient) dag_stop #

fn (mut client DaguClient) dag_stop(name string) !PostDagActionResponse

fn (DaguClient) dag_suspend #

fn (mut client DaguClient) dag_suspend(name string) !PostDagActionResponse

fn (DaguClient) dags_list #

fn (mut client DaguClient) dags_list() !ListDagsResponse

Creates a new DAG.

struct ApiError #

struct ApiError {
	code             int    @[skip]
	message          string @[required]
	detailed_message string @[json: 'detailedMessage'; required]
}

struct Call #

struct Call {
pub:
	function string
	args     map[string]string
}

https://dagu.readthedocs.io/en/latest/yaml_format.html#id9

struct Condition #

struct Condition {
pub:
	condition string // QUESTION: how to use this?
	expected  string
}

struct Config #

@[params]
struct Config {
pub mut:
	url       string
	username  string
	password  string
	apisecret string @[secret]
}

struct ContinueOn #

struct ContinueOn {
pub:
	failure bool
	skipped bool
}

struct DAG #

@[heap]
struct DAG {
pub mut:
	path                 string  @[skip]
	name                 string  @[json: 'Name']        // The name of the DAG, which is optional. The default name is the name of the file.
	description          ?string @[json: 'Description'] // A brief description of the DAG.
	schedule             ?string            // The execution schedule of the DAG in Cron expression format.
	group                ?string            // The group name to organize DAGs, which is optional.
	tags                 ?string            // Free tags that can be used to categorize DAGs, separated by commas.
	env                  ?map[string]string // Environment variables that can be accessed by the DAG and its steps.
	log_dir              ?string            // The directory where the standard output is written. The default value is ${DAGU_HOME}/logs/dags.
	restart_wait_sec     ?int               // The number of seconds to wait after the DAG process stops before restarting it.
	hist_retention_days  ?int               // The number of days to retain execution history (not for log files).
	delay_sec            ?int               // The interval time in seconds between steps.
	max_active_runs      ?int               // The maximum number of parallel running steps.
	params               ?string            // The default parameters that can be referred to by $1, $2, and so on.
	preconditions        ?[]Condition       // The conditions that must be met before a DAG or step can run.
	mail_on              ?MailOn            // Whether to send an email notification when a DAG or step fails or succeeds.
	max_cleanup_time_sec ?int               // The maximum time to wait after sending a TERM signal to running steps before killing them.
	handler_on           ?HandlerOn         // The command to execute when a DAG or step succeeds, fails, cancels, or exits.
	functions            ?[]Function        // https://dagu.readthedocs.io/en/latest/yaml_format.html#id9
	steps                []Step @[json: 'Steps'] // A list of steps to execute in the DAG.
}

fn (DAG) step_add #

fn (mut d DAG) step_add(args_ StepArgs) !&Step

fn (DAG) step_get #

fn (mut d DAG) step_get(nr int) !Step

struct DAGArgs #

@[params]
struct DAGArgs {
pub:
	name                 string             // The name of the DAG, which is optional. The default name is the name of the file.
	description          ?string            // A brief description of the DAG.
	tags                 ?string            // Free tags that can be used to categorize DAGs, separated by commas.
	env                  ?map[string]string // Environment variables that can be accessed by the DAG and its steps.
	restart_wait_sec     ?int               // The number of seconds to wait after the DAG process stops before restarting it.
	hist_retention_days  ?int               // The number of days to retain execution history (not for log files).
	delay_sec            ?int               // The interval time in seconds between steps.
	max_active_runs      ?int               // The maximum number of parallel running steps.
	max_cleanup_time_sec ?int               // The maximum time to wait after sending a TERM signal to running steps before killing them.
}

struct DagListItem #

struct DagListItem {
pub:
	file      string    @[json: 'File']
	dir       string    @[json: 'Dir']
	dag       DAG       @[json: 'DAG']
	status    DagStatus @[json: 'Status']
	suspended bool      @[json: 'Suspended']
	error     string    @[json: 'Error']
	error_t   string    @[json: 'ErrorT']
}

struct DagStatus #

struct DagStatus {
	request_id  string @[json: 'RequestID']
	name        string @[json: 'Name']
	status      int    @[json: 'Status']
	status_text string @[json: 'StatusText']
	pid         int    @[json: 'PID']
	started_at  string @[json: 'StartedAt']
	finished_at string @[json: 'FinishedAt']
	log         string @[json: 'Log']
	params      string @[json: 'Params']
}

struct DaguClient_ #

struct DaguClient_[T] {
	base.BaseConfig[T]
pub mut:
	connection &httpconnection.HTTPConnection
}

struct Executor #

struct Executor {
	typ string @[json: 'type']
}

struct Function #

struct Function {
pub:
	name    string
	params  string
	command string
}

https://dagu.readthedocs.io/en/latest/yaml_format.html#id9

struct HandlerOn #

struct HandlerOn {
pub:
	success string
	failure string
	cancel  string
	exit    string
}

struct ListDagsResponse #

struct ListDagsResponse {
pub:
	dags      []DagListItem @[json: 'DAGs'; required]
	errors    []string      @[json: 'Errors'; required]
	has_error bool          @[json: 'HasError'; required]
}

struct MailOn #

struct MailOn {
pub:
	failure bool
	success bool
}

struct NewDagOptions #

@[params]
struct NewDagOptions {
pub:
	overwrite bool = true // whether to overwrite existing dag with same name
	start     bool
}

struct PostDagAction #

@[params]
struct PostDagAction {
	action     DagAction @[required]
	value      string
	request_id string
	step       string
	params     string
}

struct PostDagActionResponse #

struct PostDagActionResponse {
	new_dag_id string @[json: 'NewDagID']
}

struct RepeatPolicy #

struct RepeatPolicy {
pub:
	repeat       bool
	interval_sec int @[json: 'intervalSec']
}

struct RetryPolicy #

struct RetryPolicy {
pub:
	limit        int // nr of times to retry
	interval_sec int @[json: 'intervalSec'] // sec between the retries in seconds
}

struct RetryPolicyArgs #

@[params]
struct RetryPolicyArgs {
pub:
	retry_nr       int = 1
	retry_interval int = 15
}

struct Schedule #

struct Schedule {
	expression string @[json: 'Expression']
}

pub struct DAG { pub: group string @[json: 'Group'] name string @[json: 'Name'] schedule []Schedule @[json: 'Schedule'] description string @[json: 'Description'] params []string @[json: 'Params'] default_params string @[json: 'DefaultParams'] tags []string @[json: 'Tags'] }

struct Step #

struct Step {
pub mut:
	nr             int    @[skip]
	name           string @[json: 'Name']        // The name of the step.
	description    string @[json: 'Description'] // A brief description of the step.
	dir            string // The working directory for the step.
	command        string @[json: 'Command'] // The command and parameters to execute.
	stdout         string  // The file to which the standard output is written.
	output         ?string // The variable to which the result is written.
	script         ?string // The script to execute.
	signal_on_stop ?string // The signal name (e.g., SIGINT) to be sent when the process is stopped.
	mail_on        ?MailOn // Whether to send an email notification when the step fails or succeeds.
	continue_on    ?ContinueOn   @[json: 'continueOn']   // Whether to continue to the next step, regardless of whether the step failed or not or the preconditions are met or not.
	retry_policy   ?RetryPolicy  @[json: 'retryPolicy']  // The retry policy for the step.
	repeat_policy  ?RepeatPolicy @[json: 'repeatPolicy'] // The repeat policy for the step.
	preconditions  []string // The conditions that must be met before a step can run.
	depends        []string // The step depends on the other step.
	call           ?Call    // User defined function call
	executor       ?Executor
}

fn (Step) continue_on #

fn (mut self Step) continue_on(failure bool, skipped bool)

Whether to continue to the next step, regardless of whether the step failed or not or the preconditions are met or not. arg1: failure, if true will continue if fialed arg2: skipped, if preconditions not met will still continue

fn (Step) retry_policy #

fn (mut self Step) retry_policy(args RetryPolicyArgs)

should we retry and if yes how long . args

 nrtimes        int //nr of times to retry
 interval_sec int //sec between the retries in seconds

struct StepArgs #

@[params]
struct StepArgs {
pub mut:
	nr                int
	name              string  // The name of the step.
	description       string  // A brief description of the step.
	dir               string  // The working directory for the step.
	command           string  // The command and parameters to execute.
	stdout            string  // The file to which the standard output is written.
	output            ?string // The variable to which the result is written.
	script            ?string // The script to execute.
	signal_on_stop    ?string // The signal name (e.g., SIGINT) to be sent when the process is stopped.
	continue_on_error bool
	depends           string
	retry_nr          int = 3
	retry_interval    int = 5
}