Class: Tasker::Events::Catalog
- Inherits:
-
Object
- Object
- Tasker::Events::Catalog
- Defined in:
- lib/tasker/events/catalog.rb
Overview
Event Catalog provides discovery and documentation for all Tasker events
This class enables developers to explore and understand the event system with runtime introspection, payload schemas, and usage examples.
All metadata is now sourced from Constants::EventDefinitions to ensure a single source of truth between registration and documentation.
Usage: # Browse all available events Tasker::Events.catalog
# Get details about a specific event Tasker::Events.event_info('task.completed')
# List events by category Tasker::Events.task_events Tasker::Events.step_events
Defined Under Namespace
Classes: CatalogPrinter, CustomEventRegistrar, ExamplePayloadGenerator
Class Method Summary collapse
-
.catalog ⇒ Hash
Get complete event catalog with descriptions and schemas Now reads directly from EventDefinitions for consistency.
-
.complete_catalog ⇒ Hash
Get complete catalog including custom events.
-
.custom_events ⇒ Hash
Get only custom events.
-
.event_info(event_name) ⇒ Hash?
Get information about a specific event.
-
.events_by_namespace(namespace) ⇒ Hash
Get events by namespace (e.g., 'order', 'payment').
-
.observability_events ⇒ Hash
Get all observability events.
-
.print_catalog(output: nil) ⇒ void
Pretty print the catalog for console exploration.
-
.register_custom_event(event_name, metadata = {}) ⇒ void
Register a custom event (called by BaseSubscriber).
-
.search_events(query) ⇒ Hash
Search events by name or description.
-
.step_events ⇒ Hash
Get all step-related events.
-
.task_events ⇒ Hash
Get all task-related events.
-
.workflow_events ⇒ Hash
Get all workflow orchestration events.
Class Method Details
.catalog ⇒ Hash
Get complete event catalog with descriptions and schemas Now reads directly from EventDefinitions for consistency
31 32 33 |
# File 'lib/tasker/events/catalog.rb', line 31 def catalog @catalog ||= build_catalog_from_definitions end |
.complete_catalog ⇒ Hash
Get complete catalog including custom events
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/tasker/events/catalog.rb', line 77 def complete_catalog system_catalog = catalog custom_events_data = Tasker::Events::CustomRegistry.instance.custom_events # Format custom events to match system catalog structure formatted_custom = custom_events_data.transform_values do |event| { name: event[:name], category: event[:category], description: event[:description], fired_by: event[:fired_by], payload_schema: {}, # MVP: no schema validation yet example_payload: {} # MVP: no examples yet } end system_catalog.merge(formatted_custom) end |
.custom_events ⇒ Hash
Get only custom events
99 100 101 |
# File 'lib/tasker/events/catalog.rb', line 99 def custom_events complete_catalog.select { |_, event| event[:category] == 'custom' } end |
.event_info(event_name) ⇒ Hash?
Get information about a specific event
39 40 41 42 43 44 |
# File 'lib/tasker/events/catalog.rb', line 39 def event_info(event_name) definition = Tasker::Constants::EventDefinitions.find_by(constant: event_name.to_s) return nil unless definition format_event_info(definition) end |
.events_by_namespace(namespace) ⇒ Hash
Get events by namespace (e.g., 'order', 'payment')
118 119 120 |
# File 'lib/tasker/events/catalog.rb', line 118 def events_by_namespace(namespace) complete_catalog.select { |name, _| name.start_with?("#{namespace}.") } end |
.observability_events ⇒ Hash
Get all observability events
70 71 72 |
# File 'lib/tasker/events/catalog.rb', line 70 def observability_events catalog.select { |_, event| event[:category] == 'observability' } end |
.print_catalog(output: nil) ⇒ void
This method returns an undefined value.
Pretty print the catalog for console exploration
135 136 137 |
# File 'lib/tasker/events/catalog.rb', line 135 def print_catalog(output: nil) CatalogPrinter.print(complete_catalog, output) end |
.register_custom_event(event_name, metadata = {}) ⇒ void
This method returns an undefined value.
Register a custom event (called by BaseSubscriber)
127 128 129 |
# File 'lib/tasker/events/catalog.rb', line 127 def register_custom_event(event_name, = {}) CustomEventRegistrar.register(event_name, , self) end |
.search_events(query) ⇒ Hash
Search events by name or description
107 108 109 110 111 112 |
# File 'lib/tasker/events/catalog.rb', line 107 def search_events(query) complete_catalog.select do |name, event| name.downcase.include?(query.downcase) || event[:description].downcase.include?(query.downcase) end end |
.step_events ⇒ Hash
Get all step-related events
56 57 58 |
# File 'lib/tasker/events/catalog.rb', line 56 def step_events catalog.select { |_, event| event[:category] == 'step' } end |
.task_events ⇒ Hash
Get all task-related events
49 50 51 |
# File 'lib/tasker/events/catalog.rb', line 49 def task_events catalog.select { |_, event| event[:category] == 'task' } end |
.workflow_events ⇒ Hash
Get all workflow orchestration events
63 64 65 |
# File 'lib/tasker/events/catalog.rb', line 63 def workflow_events catalog.select { |_, event| event[:category] == 'workflow' } end |