Class: Hatchet::Features::Cron
- Inherits:
-
Object
- Object
- Hatchet::Features::Cron
- Defined in:
- lib/hatchet/features/cron.rb
Overview
Cron client for managing cron workflow triggers within Hatchet
This class provides a high-level interface for creating, deleting, listing, and retrieving cron workflow triggers.
Constant Summary collapse
- CRON_ALIASES =
%w[@yearly @annually @monthly @weekly @daily @hourly].freeze
Instance Method Summary collapse
-
#create(workflow_name:, cron_name:, expression:, input: {}, additional_metadata: {}, priority: nil) ⇒ Object
Create a new workflow cron trigger.
-
#delete(cron_id) ⇒ void
Delete a workflow cron trigger.
-
#get(cron_id) ⇒ Object
Retrieve a specific workflow cron trigger by ID.
-
#initialize(rest_client, config) ⇒ void
constructor
Initializes a new Cron client instance.
-
#list(offset: nil, limit: nil, workflow_id: nil, additional_metadata: nil, order_by_field: nil, order_by_direction: nil, workflow_name: nil, cron_name: nil) ⇒ Object
List cron workflow triggers matching the specified criteria.
Constructor Details
#initialize(rest_client, config) ⇒ void
Initializes a new Cron client instance
29 30 31 32 33 34 |
# File 'lib/hatchet/features/cron.rb', line 29 def initialize(rest_client, config) @rest_client = rest_client @config = config @workflow_api = HatchetSdkRest::WorkflowApi.new(rest_client) @workflow_run_api = HatchetSdkRest::WorkflowRunApi.new(rest_client) end |
Instance Method Details
#create(workflow_name:, cron_name:, expression:, input: {}, additional_metadata: {}, priority: nil) ⇒ Object
Create a new workflow cron trigger
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/hatchet/features/cron.rb', line 55 def create(workflow_name:, cron_name:, expression:, input: {}, additional_metadata: {}, priority: nil) validated_expression = validate_cron_expression(expression) request = HatchetSdkRest::CreateCronWorkflowTriggerRequest.new( cron_name: cron_name, cron_expression: validated_expression, input: input, additional_metadata: , priority: priority, ) @workflow_run_api.cron_workflow_trigger_create( @config.tenant_id, @config.apply_namespace(workflow_name), request, ) end |
#delete(cron_id) ⇒ void
This method returns an undefined value.
Delete a workflow cron trigger
80 81 82 |
# File 'lib/hatchet/features/cron.rb', line 80 def delete(cron_id) @workflow_api.workflow_cron_delete(@config.tenant_id, cron_id.to_s) end |
#get(cron_id) ⇒ Object
Retrieve a specific workflow cron trigger by ID
122 123 124 |
# File 'lib/hatchet/features/cron.rb', line 122 def get(cron_id) @workflow_api.workflow_cron_get(@config.tenant_id, cron_id.to_s) end |
#list(offset: nil, limit: nil, workflow_id: nil, additional_metadata: nil, order_by_field: nil, order_by_direction: nil, workflow_name: nil, cron_name: nil) ⇒ Object
List cron workflow triggers matching the specified criteria
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/hatchet/features/cron.rb', line 98 def list(offset: nil, limit: nil, workflow_id: nil, additional_metadata: nil, order_by_field: nil, order_by_direction: nil, workflow_name: nil, cron_name: nil) @workflow_api.cron_workflow_list( @config.tenant_id, { offset: offset, limit: limit, workflow_id: workflow_id, additional_metadata: (), order_by_field: order_by_field, order_by_direction: order_by_direction, workflow_name: workflow_name, cron_name: cron_name, }, ) end |