-
Notifications
You must be signed in to change notification settings - Fork 461
Events
The OBS has a pub/sub event system built in. Events describe something that happened throughout the OBS (backend and frontend). Things like
- The build of package FOO in project BAR has failed
- The submit request #12345 was accepted
- A comment was created in project FOO
Events are published, subscribers express interest in certain events, subsystems then react to published events. For instance:
- User henne subscribes for mails about events that concern packages where he is maintainer
- An event that concerns the package, where henne is maintainer, is published
- Based on the subscription a mail is sent to henne, containing details about the event
See Event::Base and classes inheriting from it (e.g. Event::CommentForProject or Event::RequestStatechange).
We publish an event by creating an instance of Event in the database. The code below will, for instance, create an event that describes that a the package obs-server was branched by the user henne.
Event::BranchCommand.create(project: 'OBS:Server:Unstable',
package: 'obs-server',
targetproject: 'home:henne',
targetpackage: 'obs-server',
user: 'henne')Throughout the app Event instances get created by
- code like above
- the OBS backend
Most of the events happen in the OBS backend. It exposes them on its /lastnotifications API. We poll this API periodically (via clockwork) with the UpdateNotificationEvents class. That class then creates instances of Event in the database.
We subscribe to an event by creating an instance of EventSubscription in the database. The code below will, for instance, create an email subscription for the user henne for all Event::BuildFail events, concerning packages henne is maintainer of.
EventSubscription.create(eventtype: "Event::BuildFail",
receiver_role: "maintainer",
user: User.find_by(login: 'henne'),
channel: "instant_email",
enabled: true)There are several subsystems that react to the publishing of events.
-
NotificationServiceis creating web notifications and RSS feeds for users. -
EventMaileris sending emails to users.
Both are triggered by SendEventEmailsJob which is scheduled periodically by clockwork.
There are several other things that react to events.
-
CreateProjectLogEntryJobis filling the ProjectLog with entries. This job is scheduled by many of the events. -
UpdateBackendInfosJobkeeps The-BackendPackage-Cache fresh. This job is scheduled by commit and service events. -
UpdateReleasedBinariesJobtracks published packages. This job is scheduled by packtrack events.
Many events are also published on the RabbitMQ message bus when they happen.
Event classes that respond to the the message_bus_routing_key method are send to the obs exchange. Event classes that respond to the method metric_fields are send to the metrics exchange.
The CleanupEvents job destroys all the Event instances where the other subs-systems have done their job. This state is tracked in the Event instance.
Jobs that inherit from CreateJob increase the Event.undone_jobs attribute by 1 if they are scheduled. And subtract Event.undone_jobs attribute by 1 if they are finished. SendEventEmailsJob sets Event.mails_sent to true once it finishes.
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Test in kanku
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- Package Versions
- next_rails
- Ruby Update
- Rails Profiling
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- Brakeman
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models
- RFC: Hotwire Turbo Frames Pattern