features

package
v0.56.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

package features provides functionality for interacting with hatchet features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCronExpression

func ValidateCronExpression(expression string) bool

ValidateCronExpression validates that a string is a valid cron expression.

Types

type CreateCronTrigger

type CreateCronTrigger struct {
	// Name is the unique identifier for the cron trigger.
	Name string `json:"name"`

	// Expression is the cron expression that defines the schedule.
	Expression string `json:"expression"`

	// Input is the optional input data for the workflow.
	Input map[string]interface{} `json:"input,omitempty"`

	// AdditionalMetadata is optional metadata to associate with the cron trigger.
	AdditionalMetadata map[string]interface{} `json:"additionalMetadata,omitempty"`
}

CreateCronTrigger contains the configuration for creating a cron trigger.

type CreateRatelimitOpts

type CreateRatelimitOpts struct {
	// key is the unique identifier for the rate limit
	Key string
	// limit is the maximum number of requests allowed within the duration
	Limit int
	// duration specifies the time period for the rate limit
	Duration types.RateLimitDuration
}

createRatelimitOpts contains options for creating or updating a rate limit.

type CreateScheduledRunTrigger

type CreateScheduledRunTrigger struct {
	// TriggerAt specifies when the workflow should be triggered.
	TriggerAt time.Time `json:"triggerAt"`

	// Input is the optional input data for the workflow.
	Input map[string]interface{} `json:"input,omitempty"`

	// AdditionalMetadata is optional metadata to associate with the scheduled run.
	AdditionalMetadata map[string]interface{} `json:"additionalMetadata,omitempty"`
}

CreateScheduledRunTrigger contains the configuration for creating a scheduled run trigger.

type CronsClient

type CronsClient interface {
	// Create creates a new cron workflow trigger.
	Create(workflowName string, cron CreateCronTrigger, ctx ...context.Context) (*rest.CronWorkflows, error)

	// Delete removes a cron workflow trigger.
	Delete(cronId string, ctx ...context.Context) error

	// List retrieves a collection of cron workflow triggers based on the provided parameters.
	List(opts rest.CronWorkflowListParams, ctx ...context.Context) (*rest.CronWorkflowsList, error)

	// Get retrieves a specific cron workflow trigger by its ID.
	Get(cronId string, ctx ...context.Context) (*rest.CronWorkflows, error)
}

CronsClient provides methods for interacting with cron workflow triggers in the Hatchet platform.

func NewCronsClient

func NewCronsClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) CronsClient

NewCronsClient creates a new client for interacting with cron workflow triggers.

type InvalidCronExpressionError

type InvalidCronExpressionError struct {
	Expression string
}

InvalidCronExpressionError represents an error when an invalid cron expression is provided.

func (*InvalidCronExpressionError) Error

type MetricsClient

type MetricsClient interface {
	// GetWorkflowMetrics retrieves metrics for a specific workflow.
	GetWorkflowMetrics(workflowId string, opts *rest.WorkflowGetMetricsParams, ctx ...context.Context) (*rest.WorkflowMetrics, error)

	// GetQueueMetrics retrieves tenant-wide queue metrics.
	GetQueueMetrics(opts *rest.TenantGetQueueMetricsParams, ctx ...context.Context) (*rest.TenantGetQueueMetricsResponse, error)

	// GetTaskQueueMetrics retrieves tenant-wide step run queue metrics.
	GetTaskQueueMetrics(ctx ...context.Context) (*rest.TenantGetStepRunQueueMetricsResponse, error)
}

MetricsClient provides methods for retrieving metrics data in the Hatchet platform.

func NewMetricsClient

func NewMetricsClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) MetricsClient

NewMetricsClient creates a new client for interacting with metrics.

type RateLimitsClient

type RateLimitsClient interface {
	// upsert creates or updates a rate limit with the provided options.
	Upsert(opts CreateRatelimitOpts) error

	// list retrieves rate limits based on the provided parameters (optional).
	List(opts *rest.RateLimitListParams, ctx ...context.Context) (*rest.RateLimitListResponse, error)
}

rateLimitsClient provides an interface for managing rate limits.

func NewRateLimitsClient

func NewRateLimitsClient(
	api *rest.ClientWithResponses,
	tenantId *string,
	admin *v0Client.AdminClient,
) RateLimitsClient

newRateLimitsClient creates a new rateLimitsClient with the provided api client, tenant id, and admin client.

type RunsClient

type RunsClient interface {
	// Get retrieves a workflow run by its ID.
	Get(runId string, ctx ...context.Context) (*rest.V1WorkflowRunGetResponse, error)

	// GetDetails retrieves detailed information about a workflow run by its ID.
	GetDetails(runId string, ctx ...context.Context) (*rest.WorkflowRunGetShapeResponse, error)

	// List retrieves a collection of workflow runs based on the provided parameters.
	List(opts rest.V1WorkflowRunListParams, ctx ...context.Context) (*rest.V1WorkflowRunListResponse, error)

	// Replay requests a task to be replayed within a workflow run.
	Replay(opts rest.V1ReplayTaskRequest, ctx ...context.Context) (*rest.V1TaskReplayResponse, error)

	// Cancel requests cancellation of a specific task within a workflow run.
	Cancel(opts rest.V1CancelTaskRequest, ctx ...context.Context) (*rest.V1TaskCancelResponse, error)
}

RunsClient provides methods for interacting with workflow runs in the Hatchet platform.

func NewRunsClient

func NewRunsClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) RunsClient

NewRunsClient creates a new client for interacting with workflow runs.

type SchedulesClient

type SchedulesClient interface {
	// Create creates a new scheduled workflow run.
	Create(workflowName string, trigger CreateScheduledRunTrigger, ctx ...context.Context) (*rest.ScheduledWorkflows, error)

	// Delete removes a scheduled workflow run.
	Delete(scheduledRunId string, ctx ...context.Context) error

	// List retrieves a collection of scheduled workflow runs based on the provided parameters.
	List(opts rest.WorkflowScheduledListParams, ctx ...context.Context) (*rest.ScheduledWorkflowsList, error)

	// Get retrieves a specific scheduled workflow run by its ID.
	Get(scheduledRunId string, ctx ...context.Context) (*rest.ScheduledWorkflows, error)
}

SchedulesClient provides methods for interacting with workflow schedules in the Hatchet platform.

func NewSchedulesClient

func NewSchedulesClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) SchedulesClient

NewSchedulesClient creates a new client for interacting with workflow schedules.

type WorkersClient

type WorkersClient interface {
	// Get retrieves a worker by its ID.
	Get(workerId string, ctx ...context.Context) (*rest.Worker, error)

	// List retrieves all workers for the tenant.
	List(ctx ...context.Context) (*rest.WorkerList, error)

	// IsPaused checks if a worker is paused.
	IsPaused(workerId string, ctx ...context.Context) (bool, error)

	// Pause pauses a worker.
	Pause(workerId string, ctx ...context.Context) (*rest.Worker, error)

	// Unpause unpauses a worker.
	Unpause(workerId string, ctx ...context.Context) (*rest.Worker, error)
}

WorkersClient provides methods for interacting with workers in the Hatchet platform.

func NewWorkersClient

func NewWorkersClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) WorkersClient

NewWorkersClient creates a new client for interacting with workers.

type WorkflowsClient

type WorkflowsClient interface {
	// Get retrieves a workflow by its name.
	Get(workflowName string, ctx ...context.Context) (*rest.Workflow, error)

	// GetId retrieves a workflow by its name.
	GetId(workflowName string, ctx ...context.Context) (uuid.UUID, error)

	// List retrieves all workflows for the tenant with optional filtering parameters.
	List(opts *rest.WorkflowListParams, ctx ...context.Context) (*rest.WorkflowList, error)

	// Delete removes a workflow by its name.
	Delete(workflowName string, ctx ...context.Context) (*rest.WorkflowDeleteResponse, error)
}

WorkflowsClient provides methods for interacting with workflows in the Hatchet platform.

func NewWorkflowsClient

func NewWorkflowsClient(
	api *rest.ClientWithResponses,
	tenantId *string,
) WorkflowsClient

NewWorkflowsClient creates a new client for interacting with workflows.

Jump to

Keyboard shortcuts

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