Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobQueue observer #45

Open
adam-fowler opened this issue Dec 31, 2024 · 1 comment
Open

JobQueue observer #45

adam-fowler opened this issue Dec 31, 2024 · 1 comment

Comments

@adam-fowler
Copy link
Member

adam-fowler commented Dec 31, 2024

Add array of observers to queue. When events like a job is added, finished, failed occur these observers are informed. This allows us to separate out non-core job handling code into individual observers. eg

  • publishing events to service eg mqtt, rabbitmq, AWS SQS
  • schedule new jobs based on jobs finishing

If we define an observer protocol there are two ways we can define this

  1. A protocol that includes methods for every event
  2. A protocol that has one function onEvent which is provided with a event type (with additional metadata)

2 has the advantages of being more flexible than 1 but it might have performance issues as every observer would have to get the event type before working out what to do with it.

@Joannis @thoven87

@thoven87
Copy link
Contributor

Add array of observers to queue. When events like a job is added, finished, failed occur these observers are informed. This allows us to separate out non-core job handling code into individual observers. eg

  • publishing events to service eg mqtt, rabbitmq, AWS SQS
  • schedule new jobs based on jobs finishing

If we define an observer protocol there are two ways we can define this

  1. A protocol that includes methods for every event
  2. A protocol that has one function onEvent which is provided with a event type (with additional metadata)

2 has the advantages of being more flexible than 1 but it might have performance issues as every observer would have to get the event type before working out what to do with it.

@Joannis @thoven87

I agree with defining a protocol which includes a method for every event is more performant. What's the actual cost of the send options? Since every job would already have all possible observers by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants