Module: Tasker::Registry::EventPublisher

Extended by:
ActiveSupport::Concern
Defined in:
lib/tasker/registry/event_publisher.rb

Overview

Event publishing capabilities for registry systems

Provides standardized event publishing for registration, unregistration, and validation events across all registries.

Instance Method Summary collapse

Instance Method Details

#publish_registration_event(entity_type, entity_id, entity_class, options = {}) ⇒ Object

Publish registration event

Parameters:

  • entity_type (String)

    Type of entity being registered

  • entity_id (String)

    Unique identifier for the entity

  • entity_class (Class, String)

    Class of the entity being registered

  • options (Hash) (defaults to: {})

    Additional registration options



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

def publish_registration_event(entity_type, entity_id, entity_class, options = {})
  event_name = "#{entity_type}.registered"
  class_name = entity_class.is_a?(Class) ? entity_class.name : entity_class.to_s

  publish_event(event_name, {
                  registry_name: @registry_name,
                  entity_type: entity_type,
                  entity_id: entity_id,
                  entity_class: class_name,
                  options: options,
                  registered_at: Time.current,
                  correlation_id: correlation_id
                })
end

#publish_registry_stats_event(stats) ⇒ Object

Publish registry statistics collection event

Parameters:

  • stats (Hash)

    Registry statistics



81
82
83
84
85
86
87
88
# File 'lib/tasker/registry/event_publisher.rb', line 81

def publish_registry_stats_event(stats)
  publish_event('registry.stats_collected', {
                  registry_name: @registry_name,
                  stats: stats,
                  collected_at: Time.current,
                  correlation_id: correlation_id
                })
end

#publish_unregistration_event(entity_type, entity_id, entity_class) ⇒ Object

Publish unregistration event

Parameters:

  • entity_type (String)

    Type of entity being unregistered

  • entity_id (String)

    Unique identifier for the entity

  • entity_class (Class, String)

    Class of the entity being unregistered



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tasker/registry/event_publisher.rb', line 45

def publish_unregistration_event(entity_type, entity_id, entity_class)
  event_name = "#{entity_type}.unregistered"
  class_name = entity_class.is_a?(Class) ? entity_class.name : entity_class.to_s

  publish_event(event_name, {
                  registry_name: @registry_name,
                  entity_type: entity_type,
                  entity_id: entity_id,
                  entity_class: class_name,
                  unregistered_at: Time.current,
                  correlation_id: correlation_id
                })
end

#publish_validation_failed_event(entity_type, entity_class, error) ⇒ Object

Publish validation failure event

Parameters:

  • entity_type (String)

    Type of entity that failed validation

  • entity_class (Class, String)

    Class of the entity that failed validation

  • error (StandardError)

    The validation error that occurred



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tasker/registry/event_publisher.rb', line 64

def publish_validation_failed_event(entity_type, entity_class, error)
  event_name = "#{entity_type}.validation_failed"
  class_name = entity_class.is_a?(Class) ? entity_class.name : entity_class.to_s

  publish_event(event_name, {
                  registry_name: @registry_name,
                  entity_type: entity_type,
                  entity_class: class_name,
                  validation_error: error.message,
                  failed_at: Time.current,
                  correlation_id: correlation_id
                })
end