cmd

package
v1.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: GPL-2.0, GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLogFilename

func BuildLogFilename(config LogFileSettings) string

BuildLogFilename constructs the log filename using the prefix, safe DAG name, current timestamp, and a truncated version of the request ID.

func CmdDry

func CmdDry() *cobra.Command

func CmdRestart

func CmdRestart() *cobra.Command

func CmdRetry

func CmdRetry() *cobra.Command

func CmdScheduler

func CmdScheduler() *cobra.Command

func CmdServer

func CmdServer() *cobra.Command

func CmdStart

func CmdStart() *cobra.Command

func CmdStartAll

func CmdStartAll() *cobra.Command

func CmdStatus

func CmdStatus() *cobra.Command

func CmdStop

func CmdStop() *cobra.Command

func CmdVersion

func CmdVersion() *cobra.Command

func CreateLogFile

func CreateLogFile(filepath string) (*os.File, error)

CreateLogFile opens (or creates) the log file with flags for creation, write-only access, appending, and synchronous I/O. It sets file permissions to 0644.

func NewCommand

func NewCommand(cmd *cobra.Command, flags []commandLineFlag, run func(cmd *Context, args []string) error) *cobra.Command

NewCommand creates a new command instance with the given cobra command and run function.

func SetupLogDirectory

func SetupLogDirectory(config LogFileSettings) (string, error)

SetupLogDirectory creates (if necessary) and returns the log directory based on the log file settings. It uses a safe version of the DAG name to avoid issues with invalid filesystem characters.

func ValidateSettings

func ValidateSettings(config LogFileSettings) error

ValidateSettings checks that essential fields are provided. It requires that DAGName is not empty and that at least one log directory is specified.

Types

type Context

type Context struct {
	*cobra.Command
	// contains filtered or unexported fields
}

Context holds the configuration for a command.

func NewContext

func NewContext(ctx context.Context, cfg *config.Config) *Context

NewContext creates a setup instance from an existing configuration.

func (*Context) Client

func (s *Context) Client(opts ...clientOption) (client.Client, error)

Client initializes a Client using the provided options. If not supplied, it creates default DAGStore and HistoryStore instances.

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

Deadline implements context.Context.

func (*Context) Done

func (c *Context) Done() <-chan struct{}

Done implements context.Context.

func (*Context) Err

func (c *Context) Err() error

Err implements context.Context.

func (*Context) LogToFile

func (c *Context) LogToFile(f *os.File)

LogToFile creates a new logger context with a file writer.

func (*Context) OpenLogFile

func (ctx *Context) OpenLogFile(
	prefix string,
	dag *digraph.DAG,
	requestID string,
) (*os.File, error)

OpenLogFile creates and opens a log file for a given DAG execution. It evaluates the log directory, validates settings, creates the log directory, builds a filename using the current timestamp and request ID, and then opens the file.

func (*Context) Value

func (c *Context) Value(key any) any

Value implements context.Context.

type LogFileSettings

type LogFileSettings struct {
	Prefix    string // Prefix for the log filename (e.g. "start_", "retry_").
	LogDir    string // Base directory for logs.
	DAGLogDir string // Optional alternative log directory specified by the DAG.
	DAGName   string // Name of the DAG; used for generating a safe directory name.
	RequestID string // Unique request ID used in the filename.
}

LogFileSettings defines configuration for log file creation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL