Class: Tasker::Events::Publisher
- Inherits:
-
Object
- Object
- Tasker::Events::Publisher
- Includes:
- Singleton, Concerns::IdempotentStateTransitions
- Defined in:
- lib/tasker/events/publisher.rb
Overview
Core event infrastructure for the Tasker system
This publisher provides the core event infrastructure using dry-events. It handles event registration and basic publishing capabilities.
Events are now statically defined in constants.rb and registered here. State machine mappings and metadata are loaded from YAML.
For application usage, use the EventPublisher concern which provides clean domain-specific methods that build standardized payloads:
include Tasker::Concerns::EventPublisher
publish_step_completed(step, additional_context: {...})
publish_task_failed(task, error_message: "...")
Instance Method Summary collapse
-
#initialize ⇒ Publisher
constructor
A new instance of Publisher.
-
#publish(event_name, payload = {}) ⇒ void
Core publish method with automatic timestamp enhancement.
Methods included from Concerns::IdempotentStateTransitions
#conditional_transition_to, #in_any_state?, #safe_current_state, #safe_transition_to
Constructor Details
#initialize ⇒ Publisher
29 30 31 32 |
# File 'lib/tasker/events/publisher.rb', line 29 def initialize # Register all static events from constants register_static_events end |
Instance Method Details
#publish(event_name, payload = {}) ⇒ void
This method returns an undefined value.
Core publish method with automatic timestamp enhancement
This is the primary method used by the EventPublisher concern. Applications should use the EventPublisher concern methods instead of calling this directly.
43 44 45 46 47 48 49 50 51 |
# File 'lib/tasker/events/publisher.rb', line 43 def publish(event_name, payload = {}) # Ensure timestamp is always present in the payload enhanced_payload = { timestamp: Time.current }.merge(payload) # Call the parent publish method super(event_name, enhanced_payload) end |