Class: Hyrax::Publisher
- Inherits:
-
Object
- Object
- Hyrax::Publisher
- Includes:
- Singleton
- Defined in:
- lib/hyrax/publisher.rb
Overview
audit Hyrax code (and dependencies!) for places where events should be published, but are not.
this API replaces an older ‘Hyrax::Callbacks` interface, with added thread safety and capacity for many listeners on a single publication stream.
we call this “Publisher” to differentiate from the ‘Hyrax::Event` model. This class is a `Dry::Events` publisher.
This is an application-wide publisher for Hyrax’s Pub/Sub interface.
Hyrax publishes events on a variety of streams. The streams are namespaced using ‘dry-rb`’s dot notation idiom to help with organization. Namespaces reflect the kinds of resources the event applied to.
- `batch`: events related to the performance of `BatchCreateJob`
- `collection`: events related to the lifecycle of PCDM Collections
- `file`: events related to the lifecycle of File/FileMetadata
- `file.set`: events related to the lifecycle of Hydra Works FileSets
- `object`: events related to the lifecycle of all PCDM Objects
Applications SHOULD publish events whenever the relevant actions are performed. While Hyrax provides certain out-of-the-box listeners to power (e.g.) notifications, event streams are useful for much more: implementing local logging or instrumentation, adding application-specific callback-like handlers, etc… Ensuring events are consistently published is key to their usefulness.
Below is an example of subscribing using an anonymous block. A potential disadvantage of an anonymous block is that you cannot easily unsubscribe to that block.
Below is an example of subscribing using an object. A potential advantage of subscribing with an object is that you can later unsubscribe the object.
Registered Events collapse
- #batch.created ⇒ Object readonly
- #collection.deleted ⇒ Object readonly
Registered Events collapse
Instance Attribute Details
#batch.created ⇒ Object (readonly)
98 |
# File 'lib/hyrax/publisher.rb', line 98 register_event('batch.created') |
#collection.deleted ⇒ Object (readonly)
102 |
# File 'lib/hyrax/publisher.rb', line 102 register_event('collection.deleted') |
Instance Method Details
#default_listeners ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/hyrax/publisher.rb', line 217 def default_listeners @default_listeners ||= [Hyrax::Listeners::ACLIndexListener.new, Hyrax::Listeners::BatchNotificationListener.new, Hyrax::Listeners::FileListener.new, Hyrax::Listeners::FileMetadataListener.new, Hyrax::Listeners::FileSetLifecycleListener.new, Hyrax::Listeners::FileSetLifecycleNotificationListener.new, Hyrax::Listeners::MemberCleanupListener.new, Hyrax::Listeners::MetadataIndexListener.new, Hyrax::Listeners::ObjectLifecycleListener.new, Hyrax::Listeners::TrophyCleanupListener.new, Hyrax::Listeners::WorkflowListener.new].freeze end |