Documentation
¶
Index ¶
- Variables
- func NewMemoryRegistry() *memoryRegistry
- func NewTaskCreator(provider SourceProvider, engines []Engine) *taskCreator
- func NewYAMLMetadataParser(patterns ...MatchPattern) *yamlMetadataParser
- type BaseEngine
- func (e *BaseEngine) CanHandle(path string) bool
- func (e *BaseEngine) GetExecutionContext(ctx context.Context) (context.Context, context.CancelFunc)
- func (e *BaseEngine) GetExecutionTimeout(ctx context.Context) time.Duration
- func (e *BaseEngine) GetScriptContent(msg *ExecutionMessage) (string, error)
- func (e *BaseEngine) Name() string
- func (e *BaseEngine) ParseJob(path string, content []byte) (Task, error)
- type Config
- type Engine
- type ExecutionMessage
- type FetchOptions
- type FetchResponse
- type FileSystemSourceProvider
- type JSEngine
- type JSOption
- func WithJSExtension(ext string) JSOption
- func WithJSFS(dirfs fs.FS) JSOption
- func WithJSLogger(logger Logger) JSOption
- func WithJSMetadataParser(parser MetadataParser) JSOption
- func WithJSModuleLoader(loader func(path string) ([]byte, error)) JSOption
- func WithJSPanicHandler(handler func(funcName string, fields ...map[string]any)) JSOption
- func WithJSPathResolver(resolver func(base, path string) string) JSOption
- func WithJSTimeout(timeout time.Duration) JSOption
- type Logger
- type MatchPattern
- type MetadataParser
- type Option
- type Processor
- type Registry
- type Runner
- type SQLEngine
- type SQLOption
- func WithSQLClient(db *sql.DB) SQLOption
- func WithSQLDatabase(driverName, dataSourceName string) SQLOption
- func WithSQLExtension(ext string) SQLOption
- func WithSQLFS(dirfs fs.FS) SQLOption
- func WithSQLLogger(logger Logger) SQLOption
- func WithSQLMetadataParser(parser MetadataParser) SQLOption
- func WithSQLTimeout(timeout time.Duration) SQLOption
- type ScheduleQuotesProcessor
- type ScriptInfo
- type ShellEngine
- type ShellOption
- func WithShellEnvironment(env []string) ShellOption
- func WithShellExtension(ext string) ShellOption
- func WithShellFS(dirfs fs.FS) ShellOption
- func WithShellLogger(logger Logger) ShellOption
- func WithShellMetadataParser(parser MetadataParser) ShellOption
- func WithShellShell(shell string, args ...string) ShellOption
- func WithShellTimeout(timeout time.Duration) ShellOption
- func WithShellWorkingDirectory(dir string) ShellOption
- type SourceProvider
- type Task
- type TaskCreator
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTimeout is used to setup the default timeout for tasks DefaultTimeout = time.Minute DefaultSchedule = "* * * * *" )
var DefaultMatchPatterns = []MatchPattern{ { Name: "yaml", StartPattern: `^---\s*$`, EndPattern: `^---\s*$`, CommentPrefix: "", }, { Name: "javascript", StartPattern: `^/{2,}\s*config`, EndPattern: `^(?!/{2,})`, CommentPrefix: "//", IsBlock: false, }, { Name: "javascript_block", StartPattern: `^/\*\*\s*config(.*)$`, EndPattern: `^\*/`, CommentPrefix: "*", IsBlock: true, }, { Name: "shell", StartPattern: `^#{1,}\s*config`, EndPattern: `^(?!#{1,})`, CommentPrefix: "#", IsBlock: false, }, { Name: "sql", StartPattern: `^-{2,}\s*config`, EndPattern: `^(?!-{2,})`, CommentPrefix: "--", IsBlock: false, }, }
var LoggerEnabled = false
Functions ¶
func NewMemoryRegistry ¶
func NewMemoryRegistry() *memoryRegistry
func NewTaskCreator ¶
func NewTaskCreator(provider SourceProvider, engines []Engine) *taskCreator
func NewYAMLMetadataParser ¶
func NewYAMLMetadataParser(patterns ...MatchPattern) *yamlMetadataParser
Types ¶
type BaseEngine ¶
type BaseEngine struct { FileExtensions []string Timeout time.Duration MetadataParser MetadataParser FS fs.FS SourceProvider SourceProvider EngineType string Self Engine // contains filtered or unexported fields }
func NewBaseEngine ¶
func NewBaseEngine(self Engine, engingeType string, exts ...string) *BaseEngine
func (*BaseEngine) CanHandle ¶
func (e *BaseEngine) CanHandle(path string) bool
CanHandle checks if this engine can process the given file based on its extension
func (*BaseEngine) GetExecutionContext ¶
func (e *BaseEngine) GetExecutionContext(ctx context.Context) (context.Context, context.CancelFunc)
func (*BaseEngine) GetExecutionTimeout ¶
func (e *BaseEngine) GetExecutionTimeout(ctx context.Context) time.Duration
func (*BaseEngine) GetScriptContent ¶
func (e *BaseEngine) GetScriptContent(msg *ExecutionMessage) (string, error)
type Config ¶
type Config struct { Schedule string `yaml:"schedule" json:"schedule"` Retries int `yaml:"retries" json:"retries"` Timeout time.Duration `yaml:"duration" json:"duration"` NoTimeout bool `yaml:"no_timeout" json:"no_timeout"` Debug bool `yaml:"debug" json:"debug"` RunOnce bool `yaml:"run_once" json:"run_once"` ScriptType string `yaml:"script_type" json:"script_type"` Transaction bool `yaml:"transaction" json:"transaction"` Metadata map[string]any `yaml:"metadata" json:"metadata"` Env map[string]string `yaml:"env" json:"env"` }
handler options Deadline time.Time `json:"deadline"` MaxRetries int `json:"max_retries"` MaxRuns int `json:"max_runs"` RunOnce bool `json:"run_once"`
type ExecutionMessage ¶
type ExecutionMessage struct { command.BaseMessage JobID string ScriptPath string Config Config Parameters map[string]any OutputCallback func(stdout, stderr string) }
ExecutionMessage represents a request to execute a job script
func (ExecutionMessage) Type ¶
func (msg ExecutionMessage) Type() string
Type returns the message type for the command system
func (ExecutionMessage) Validate ¶
func (msg ExecutionMessage) Validate() error
Validate ensures the message contains required fields
type FetchOptions ¶
type FetchOptions struct { Method string `json:"method"` Headers map[string]string `json:"headers"` Body any `json:"body"` Timeout int `json:"timeout"` //milliseconds }
FetchOptions represents the options for the fetch function
type FetchResponse ¶
type FetchResponse struct { Status int `json:"status"` StatusText string `json:"statusText"` Headers map[string][]string `json:"headers"` URL string `json:"url"` Body []byte `json:"-"` }
FetchResponse represents the response from a fetch call
type FileSystemSourceProvider ¶
type FileSystemSourceProvider struct {
// contains filtered or unexported fields
}
func NewFileSystemSourceProvider ¶
func NewFileSystemSourceProvider(rootDir string, fss ...fs.FS) *FileSystemSourceProvider
func (*FileSystemSourceProvider) GetScript ¶
func (p *FileSystemSourceProvider) GetScript(path string) ([]byte, error)
func (*FileSystemSourceProvider) ListScripts ¶
func (p *FileSystemSourceProvider) ListScripts(ctx context.Context) ([]ScriptInfo, error)
type JSEngine ¶
type JSEngine struct { *BaseEngine // contains filtered or unexported fields }
func NewJSRunner ¶
type JSOption ¶
type JSOption func(*JSEngine)
func WithJSExtension ¶
func WithJSLogger ¶ added in v0.3.0
func WithJSMetadataParser ¶
func WithJSMetadataParser(parser MetadataParser) JSOption
WithJSMetadataParser sets a custom metadata parser
func WithJSModuleLoader ¶
func WithJSPanicHandler ¶
func WithJSPathResolver ¶
func WithJSTimeout ¶
WithJSTimeout sets the default execution timeout
type MatchPattern ¶
type MetadataParser ¶
type Option ¶
type Option func(*Runner)
func WithErrorHandler ¶
func WithMetadataParser ¶
func WithMetadataParser(parser MetadataParser) Option
func WithRegistry ¶
func WithTaskCreator ¶
func WithTaskCreator(creator TaskCreator) Option
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func (*Runner) RegisteredTasks ¶
type SQLEngine ¶
type SQLEngine struct { *BaseEngine // contains filtered or unexported fields }
func NewSQLRunner ¶
type SQLOption ¶
type SQLOption func(*SQLEngine)
func WithSQLClient ¶ added in v0.2.0
WithSQLClient sets the db client
func WithSQLDatabase ¶
WithDatabase sets the database connection
func WithSQLExtension ¶
WithSQLExtension adds file extensions that this SQLOption can handle
func WithSQLLogger ¶ added in v0.3.0
func WithSQLMetadataParser ¶
func WithSQLMetadataParser(parser MetadataParser) SQLOption
WithSQLMetadataParser sets a custom metadata parser
func WithSQLTimeout ¶
WithTimeout sets the default execution timeout
type ScheduleQuotesProcessor ¶ added in v0.2.0
type ScheduleQuotesProcessor struct{}
ScheduleQuotesProcessor ensures that schedule values like @every are properly quoted so the parser does not barf an error
type ScriptInfo ¶
type ShellEngine ¶
type ShellEngine struct { *BaseEngine // contains filtered or unexported fields }
func NewShellRunner ¶
func NewShellRunner(opts ...ShellOption) *ShellEngine
func (*ShellEngine) Execute ¶
func (e *ShellEngine) Execute(ctx context.Context, msg *ExecutionMessage) error
type ShellOption ¶
type ShellOption func(*ShellEngine)
func WithShellEnvironment ¶
func WithShellEnvironment(env []string) ShellOption
WithShellEnvironment sets additional environment variables
func WithShellExtension ¶
func WithShellExtension(ext string) ShellOption
WithShellExtension adds file extensions that this engine can handle
func WithShellFS ¶
func WithShellFS(dirfs fs.FS) ShellOption
WithShellFS sets the default filesystem timeout
func WithShellLogger ¶ added in v0.3.0
func WithShellLogger(logger Logger) ShellOption
func WithShellMetadataParser ¶
func WithShellMetadataParser(parser MetadataParser) ShellOption
WithShellMetadataParser sets a custom metadata parser
func WithShellShell ¶
func WithShellShell(shell string, args ...string) ShellOption
WithShellShell sets the shell executable and arguments
func WithShellTimeout ¶
func WithShellTimeout(timeout time.Duration) ShellOption
WithShellTimeout sets the default execution timeout
func WithShellWorkingDirectory ¶
func WithShellWorkingDirectory(dir string) ShellOption
WithShellWorkingDirectory sets the working directory for script execution