Simplify Engine and Broker Interfaces #8
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a major architectural refactoring to improve modularity, simplify core components, and clarify responsibilities. The core idea is to make brokers more self-contained by moving job consumption logic (polling/push) and serialization into the broker implementations.
Key Changes:
Simplified
Broker
Interface:Broker
interface is streamlined. Methods likeDequeue
,CreateQueue
, andCapabilities
have been removed from thecore.Broker
interface.Start(ctx context.Context, jobChan chan<- job.Job)
method is introduced. Each broker is now responsible for fetching jobs and sending them to the provided channel.Queues()
method was added to provide queue information.Removed
Poller
from Core:Poller
interface andStandardPoller
have been removed from thecore
package.pollers
package contains a helperStandardPoller
for this.Start
method.Decoupled
Serializer
from Engine:Serializer
is no longer a core component passed to theEngine
.Broker
is now responsible for its own serialization and receives aSerializer
on initialization. This better encapsulates the data format with the transport layer.Configuration Moved to Brokers:
Queues
andPollInterval
has been removed fromcore.Engine
options.Options
for each respective broker (redis.Options
,rabbitmq.Options
), making them more self-contained and easier to configure.Simplified Core and Engine:
core.Engine
is simplified. It no longer needs to create or manage aPoller
. It just callsbroker.Start()
.Worker
andWorkerPool
are also simplified, as they no longer needqueues
or aserializer
during initialization.