Class: Hatchet::TriggerWorkflowOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/trigger_options.rb

Overview

Options for triggering a workflow run

Examples:

Trigger with metadata and priority

Hatchet::TriggerWorkflowOptions.new(
  additional_metadata: { "user_id" => "123" },
  priority: 3
)

Direct Known Subclasses

ScheduleTriggerWorkflowOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(additional_metadata: nil, key: nil, priority: nil, parent_id: nil, parent_step_run_id: nil, child_index: nil, sticky: nil, desired_worker_labels: nil) ⇒ TriggerWorkflowOptions

Returns a new instance of TriggerWorkflowOptions.

Parameters:

  • additional_metadata (Hash, nil) (defaults to: nil)

    Metadata to attach to the run

  • key (String, nil) (defaults to: nil)

    Deduplication key

  • priority (Integer, nil) (defaults to: nil)

    Priority level

  • parent_id (String, nil) (defaults to: nil)

    Parent workflow run ID

  • parent_step_run_id (String, nil) (defaults to: nil)

    Parent step run ID

  • child_index (Integer, nil) (defaults to: nil)

    Child index

  • sticky (Boolean, nil) (defaults to: nil)

    Enable sticky scheduling

  • desired_worker_labels (Hash, nil) (defaults to: nil)

    Worker labels for scheduling



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hatchet/trigger_options.rb', line 44

def initialize(
  additional_metadata: nil,
  key: nil,
  priority: nil,
  parent_id: nil,
  parent_step_run_id: nil,
  child_index: nil,
  sticky: nil,
  desired_worker_labels: nil
)
  @additional_metadata = 
  @key = key
  @priority = priority
  @parent_id = parent_id
  @parent_step_run_id = parent_step_run_id
  @child_index = child_index
  @sticky = sticky
  @desired_worker_labels = desired_worker_labels
end

Instance Attribute Details

#additional_metadataHash? (readonly)

Returns Additional metadata to attach to the run.

Returns:

  • (Hash, nil)

    Additional metadata to attach to the run



13
14
15
# File 'lib/hatchet/trigger_options.rb', line 13

def 
  @additional_metadata
end

#child_indexInteger? (readonly)

Returns Child index for deterministic replay.

Returns:

  • (Integer, nil)

    Child index for deterministic replay



28
29
30
# File 'lib/hatchet/trigger_options.rb', line 28

def child_index
  @child_index
end

#desired_worker_labelsHash? (readonly)

Returns Desired worker labels for scheduling.

Returns:

  • (Hash, nil)

    Desired worker labels for scheduling



34
35
36
# File 'lib/hatchet/trigger_options.rb', line 34

def desired_worker_labels
  @desired_worker_labels
end

#keyString? (readonly)

Returns Deduplication key.

Returns:

  • (String, nil)

    Deduplication key



16
17
18
# File 'lib/hatchet/trigger_options.rb', line 16

def key
  @key
end

#parent_idString? (readonly)

Returns Parent workflow run ID (auto-set from context vars).

Returns:

  • (String, nil)

    Parent workflow run ID (auto-set from context vars)



22
23
24
# File 'lib/hatchet/trigger_options.rb', line 22

def parent_id
  @parent_id
end

#parent_step_run_idString? (readonly)

Returns Parent step run ID (auto-set from context vars).

Returns:

  • (String, nil)

    Parent step run ID (auto-set from context vars)



25
26
27
# File 'lib/hatchet/trigger_options.rb', line 25

def parent_step_run_id
  @parent_step_run_id
end

#priorityInteger? (readonly)

Returns Priority level (1-4, higher = more priority).

Returns:

  • (Integer, nil)

    Priority level (1-4, higher = more priority)



19
20
21
# File 'lib/hatchet/trigger_options.rb', line 19

def priority
  @priority
end

#stickyBoolean? (readonly)

Returns Whether to use sticky scheduling.

Returns:

  • (Boolean, nil)

    Whether to use sticky scheduling



31
32
33
# File 'lib/hatchet/trigger_options.rb', line 31

def sticky
  @sticky
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/hatchet/trigger_options.rb', line 65

def to_h
  h = {}
  h[:additional_metadata] = @additional_metadata if @additional_metadata
  h[:key] = @key if @key
  h[:priority] = @priority if @priority
  h[:parent_id] = @parent_id if @parent_id
  h[:parent_step_run_id] = @parent_step_run_id if @parent_step_run_id
  h[:child_index] = @child_index if @child_index
  h[:sticky] = @sticky unless @sticky.nil?
  h[:desired_worker_labels] = @desired_worker_labels if @desired_worker_labels
  h
end