Class: Tasker::Events::SubscriptionLoader
- Inherits:
-
Object
- Object
- Tasker::Events::SubscriptionLoader
- Defined in:
- lib/tasker/events/subscription_loader.rb
Overview
SubscriptionLoader loads event subscriptions from YAML configuration files
This class enables developers to configure event subscriptions declaratively using YAML files in config/tasker/subscriptions/
Example YAML structure: subscriptions: sentry_integration: class: 'SentrySubscriber' events: - 'task.failed' - 'step.failed' config: dsn: 'https://...' environment: 'production'
Class Method Summary collapse
-
.load_all ⇒ Hash
Load all subscription configurations from YAML files.
-
.load_subscribers ⇒ Array<BaseSubscriber>
Load and instantiate all configured subscribers.
-
.register_all_subscribers ⇒ void
Register all loaded subscribers with the event system.
-
.reload! ⇒ Hash
Reload subscription configurations (useful for development).
Class Method Details
.load_all ⇒ Hash
Load all subscription configurations from YAML files
28 29 30 |
# File 'lib/tasker/events/subscription_loader.rb', line 28 def load_all @load_all ||= load_subscription_files end |
.load_subscribers ⇒ Array<BaseSubscriber>
Load and instantiate all configured subscribers
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tasker/events/subscription_loader.rb', line 35 def load_subscribers subscribers = [] load_all.each do |name, config| subscriber = instantiate_subscriber(name, config) subscribers << subscriber if subscriber rescue StandardError => e Rails.logger.warn "Failed to load subscriber #{name}: #{e.}" end subscribers end |
.register_all_subscribers ⇒ void
This method returns an undefined value.
Register all loaded subscribers with the event system
51 52 53 54 55 56 |
# File 'lib/tasker/events/subscription_loader.rb', line 51 def register_all_subscribers load_subscribers.each do |subscriber| Rails.logger.info "Registering subscriber: #{subscriber.class.name}" # Subscribers auto-register themselves when instantiated end end |
.reload! ⇒ Hash
Reload subscription configurations (useful for development)
61 62 63 64 |
# File 'lib/tasker/events/subscription_loader.rb', line 61 def reload! @loaded_subscriptions = nil load_all end |