Closed g41797 closed 6 months ago
@viktorprogger what do you think?
I have some thoughts about the idea:
withConfig()
– deleteI think it must be encapsulated into a broker/driver/adapter. Just use __construct()
method.
isConnected()
– deleteNot all brokers can support real-time connection. Some can just open a connection, do job (push/pull) and close, so-called connectionless operations, like filesystem or an HTTP based driver.
Moreover, there are no reasons to keep the method in the interface because there are no connect()
/disconnect()
methods.
submit()
/ next()
– rename to push()
/ pull()
, existSee https://github.com/yiisoft/queue/blob/master/src/Adapter/AdapterInterface.php#L34, https://github.com/yiisoft/queue/blob/master/src/Adapter/AdapterInterface.php#L18
jobStatus()
– moveSee https://github.com/yiisoft/queue/blob/master/src/Adapter/AdapterInterface.php#L29
It's also present in another interface: https://github.com/yiisoft/queue/blob/master/src/QueueInterface.php#L46
next()
– refactorThere are interesting things that next()
(or pull()
) can return a message object from the queue. Current implementation accepts a callable and process it inside.
update()
– deleteNot all drivers can update status, because it's not just a property of an object.
If you want to change status from in process
to waiting
you must ask the worker that processes the job to stop it's work and return the job back to the queue. In some drivers it's impossible and the only possible way is to push the job as a new message.
I don't see any reasons to accept the proposal, there are no gain in UX / DX.
But I think it could be useful to have next($timeout)
method to retrieve a message.
@g41797 still no changes, all of this is available now. You made a snippet for userland. There are place for this.
Main purpose of this proposal - to simplify adding new broker to yii3 queue and queue implementation in general:
Adapter code is completelly generic and rather straightforward see below POC:
rest of the code see queue-nats repo