Module: Tasker::Orchestration::PluginIntegration

Defined in:
lib/tasker/orchestration/plugin_integration.rb

Overview

PluginIntegration provides shared access to TaskHandler plugin functionality

This module extracts the plugin integration patterns from TaskHandler and makes them available to orchestration components while preserving the extensibility that makes Tasker valuable.

Key methods preserved:

  • get_step_handler: Access to step handler plugins

  • establish_step_dependencies_and_defaults: Extensibility hook

  • update_annotations: Extensibility hook

  • schema validation: Context validation hook

Instance Method Summary collapse

Instance Method Details

#establish_step_dependencies_and_defaults_via_handler(task, steps, task_handler) ⇒ Object

Establish step dependencies and defaults using task handler hook

Parameters:

  • task (Tasker::Task)

    The task being processed

  • steps (Array<Tasker::WorkflowStep>)

    The steps to establish dependencies for

  • task_handler (Object)

    The task handler instance



57
58
59
60
61
62
# File 'lib/tasker/orchestration/plugin_integration.rb', line 57

def establish_step_dependencies_and_defaults_via_handler(task, steps, task_handler)
  # Call the task handler's hook method if it exists
  return unless task_handler.respond_to?(:establish_step_dependencies_and_defaults)

  task_handler.establish_step_dependencies_and_defaults(task, steps)
end

#get_sequence_for_task(task, task_handler) ⇒ Tasker::Types::StepSequence

Get the step sequence for a task using task handler

This delegates to the task handler’s get_sequence method which handles step template creation and dependency establishment.

Parameters:

  • task (Tasker::Task)

    The task

  • task_handler (Object)

    The task handler instance

Returns:



48
49
50
# File 'lib/tasker/orchestration/plugin_integration.rb', line 48

def get_sequence_for_task(task, task_handler)
  task_handler.get_sequence(task)
end

#get_step_handler_from_task_handler(step, task_handler) ⇒ Object

Get a step handler for a specific step

This method integrates with the TaskHandler plugin system to get the appropriate handler for a step.

Parameters:

  • step (Tasker::WorkflowStep)

    The step to get a handler for

  • task_handler (Object)

    The task handler instance

Returns:

  • (Object)

    The step handler

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tasker/orchestration/plugin_integration.rb', line 26

def get_step_handler_from_task_handler(step, task_handler)
  unless task_handler.step_handler_class_map[step.name]
    raise(Tasker::ProceduralError,
          "No registered class for #{step.name}")
  end

  handler_config = task_handler.step_handler_config_map[step.name]
  handler_class = task_handler.step_handler_class_map[step.name].to_s.camelize.constantize

  return handler_class.new if handler_config.nil?

  handler_class.new(config: handler_config)
end

#get_task_handler_class(task_name) ⇒ Class

Get task handler class for a task name

This provides access to the handler class without instantiation.

Parameters:

  • task_name (String)

    The task name

Returns:

  • (Class)

    The task handler class



118
119
120
121
# File 'lib/tasker/orchestration/plugin_integration.rb', line 118

def get_task_handler_class(task_name)
  handler_factory = Tasker::HandlerFactory.instance
  handler_factory.handler_class_for(task_name)
end

#get_task_handler_for_task(task) ⇒ Object

Get task handler instance for a task

Parameters:

Returns:

  • (Object)

    The task handler instance



103
104
105
106
107
108
109
110
# File 'lib/tasker/orchestration/plugin_integration.rb', line 103

def get_task_handler_for_task(task)
  handler_factory = Tasker::HandlerFactory.instance
  handler_factory.get(
    task.name,
    namespace_name: task.named_task.task_namespace.name,
    version: task.named_task.version
  )
end

#supports_concurrent_processing?(_task_handler) ⇒ Boolean

Check if task handler supports concurrent processing

This checks the task handler’s concurrent processing configuration to determine the appropriate processing mode.

Parameters:

  • task_handler (Object)

    The task handler instance

Returns:

  • (Boolean)

    True if concurrent processing is enabled



95
96
97
# File 'lib/tasker/orchestration/plugin_integration.rb', line 95

def supports_concurrent_processing?(_task_handler)
  true
end

#update_annotations_via_handler(task, sequence, steps, task_handler) ⇒ Object

Update annotations using task handler hook

Parameters:



70
71
72
73
74
# File 'lib/tasker/orchestration/plugin_integration.rb', line 70

def update_annotations_via_handler(task, sequence, steps, task_handler)
  return unless task_handler.respond_to?(:update_annotations)

  task_handler.update_annotations(task, sequence, steps)
end

#validate_context_via_handler(context, task_handler) ⇒ Array<String>

Validate context using task handler schema

Parameters:

  • context (Hash)

    The context to validate

  • task_handler (Object)

    The task handler with schema

Returns:

  • (Array<String>)

    Validation errors, if any



81
82
83
84
85
86
# File 'lib/tasker/orchestration/plugin_integration.rb', line 81

def validate_context_via_handler(context, task_handler)
  return [] unless task_handler.respond_to?(:schema) && task_handler.schema

  data = context.to_hash.deep_symbolize_keys
  JSON::Validator.fully_validate(task_handler.schema, data, strict: true, insert_defaults: true)
end