Class: Prosody::Commands::Execute

Inherits:
Command
  • Object
show all
Defined in:
lib/prosody/processor.rb

Overview

Command to execute a task with the given parameters.

This command encapsulates all the information needed to execute an asynchronous task in the Ruby runtime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_id, carrier, event_context, block, callback, token) ⇒ Execute

Creates a new execute command with all required parameters.

Parameters:

  • task_id (String)

    Unique identifier for the task

  • carrier (Hash)

    OpenTelemetry context carrier with trace information

  • event_context (Hash)

    Structured event fields for error reporting

  • block (Proc)

    The code to execute

  • callback (Proc)

    Called with (success, result) when complete

  • token (CancellationToken)

    Token that can be used to cancel execution



82
83
84
85
86
87
88
89
# File 'lib/prosody/processor.rb', line 82

def initialize(task_id, carrier, event_context, block, callback, token)
  @task_id = task_id
  @carrier = carrier
  @event_context = event_context
  @block = block
  @callback = callback
  @token = token
end

Instance Attribute Details

#blockObject (readonly)

The block of code to execute



66
67
68
# File 'lib/prosody/processor.rb', line 66

def block
  @block
end

#callbackObject (readonly)

Callback to invoke when execution completes or fails



69
70
71
# File 'lib/prosody/processor.rb', line 69

def callback
  @callback
end

#carrierObject (readonly)

OpenTelemetry context carrier for trace propagation



60
61
62
# File 'lib/prosody/processor.rb', line 60

def carrier
  @carrier
end

#event_contextObject (readonly)

Structured event context for error reporting



63
64
65
# File 'lib/prosody/processor.rb', line 63

def event_context
  @event_context
end

#task_idObject (readonly)

Task identifier for logging and debugging



57
58
59
# File 'lib/prosody/processor.rb', line 57

def task_id
  @task_id
end

#tokenObject (readonly)

Cancellation token for this task



72
73
74
# File 'lib/prosody/processor.rb', line 72

def token
  @token
end