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`
- `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
Instance Attribute Details
#batch.created ⇒ Object (readonly)
95 |
# File 'lib/hyrax/publisher.rb', line 95 register_event('batch.created') |
#collection.deleted ⇒ Object (readonly)
99 |
# File 'lib/hyrax/publisher.rb', line 99 register_event('collection.deleted') |