Closed xzilja closed 7 years ago
Seems like a solid approach. Note that you can also have your queue items use _state so that workers are only triggered when a queued item reaches a certain point in the process. In this way, you can make your code into an event stream and keep the workers very flexible and minimal.
It might be overkill, or particularly useful, depending on your game logic. For example, conducting an in-game "give item" could be set up like the following:
_state
to offer
_state
to pending
_state
would end up at either accept
or decline
Some neat things about this approach: Each worker is probably five or ten lines of code. Changing the logic of how an item is transferred probably just means changing the states and adding or removing workers from the mix. If the process fails at any point due to bugs or a server crashing, you'll be able to track which state it was in and probably resume the process later without any loss of items.
@katfang this is great explanation! Thank you.
I'm slowly starting to grasp
firebase-queue
and truly believe it is a great approach to workers! I'm trying to figure out if my approach below is correct way to handle several diiferent data validation tasks for my game.I've set up firebase admin and several queues like so:
Is this how you'd structure several queue tasks that need to perform different operations?