Current workflow
Currently, the HTTP gate workflow works like this:
- Client posts a payload to the gate
- The gate controller fires an event, e.g. GitHubPayloadEvent
- Nasqueron\Notifications\Listeners\NotificationListener listens to all these events, mutates it into a notification and call the relevant job, e.g. FireGitHubNotification
- The job creates a notification, as a subclass of Nasqueron\Notifications\Notifications\Notification e.g. GitHubNotification
That allows to have other listeners to work with the events e.g. PhabricatorListener listens to GitHubPayloadEvent to notify Diffusion about new commits.
Issue
Each time we need to add a new service, there are lot of files to create:
- a gate controller
- an event
- a job for this event
- a notification
The code is pretty much the same.
Furthermore, other listeners could find everything in the notification format, as it contains original payload (well GitHub sends extra headers, but we inject the event in the notification, and we don't use the guid).
Proposal
New workflow will be:
- Client posts a payload to the gate
- The gate controller directly prepares the specific notification class, probably a responsibility of the notification class (a build method?)
- The gate controller then fires directly a generic event PayloadEvent with the notification attached
An example of how to construct a specific notification class from generic arguments can be found in the Nasqueron\Notifications\Console\Commands\NotificationsPayload class.
We can then remove the Fire... jobs, the specific events, and adapt the listeners to work with the generic PayloadEvent.