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

Update handlers.lua #380

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Update handlers.lua #380

merged 1 commit into from
Oct 29, 2024

Conversation

elliotsayes
Copy link
Contributor

Handlers.once does a prepend: these should be higher priority than fallback handles.

Use case: worker pool.

  • Scenario 1: The master process resets a workers "busy" status upon receiving a "Ready" message.
  • Scenario 2: When the all workers are busy, the master process should suspend by doing Receive on (any) workers "Ready" message. Resuming the thread should take priority over resetting the status as in Scenario 1

`Handlers.once` does a `prepend`: these should be higher priority than fallback handles. 

Use case: worker pool.
- Scenario 1: The master process resets a workers "busy" status upon receiving a "Ready" message.
- Scenario 2: When the all workers are busy, the master process should suspend by doing `Receive` on (any) workers "Ready" message. Resuming the thread should take priority over resetting the status as in Scenario 1
@kprimice
Copy link
Contributor

kprimice commented Oct 25, 2024

I encountered a similar issue in a different scenario:

In my case, a process (Process A) interacts with a Liquidity Pool, receiving Credit-Notice messages. However, these Credit-Notice messages need to prepend to ensure that Process A processes them immediately, without interference from the main Credit-Notice handler.

Currently, the main handler is interfering, which prevents the Credit-Notice messages (coming from the Liquidity Pool)
from being handled with the necessary priority, and forces me to add exceptions to the main Credit-Notice handler.

@twilson63
Copy link
Collaborator

Sounds good, I am going to try to include this in the 2.0.1 release we are hoping to ship today or tomorrow, are we sure prepend is the way to go for (once) as a default, any reasons not to make this the default?

@elliotsayes
Copy link
Contributor Author

are we sure prepend is the way to go for (once) as a default, any reasons not to make this the default?

I've been thinking about this a bit, prepend also has its downsides... e.g., you expect the first call to once to take precedence over later calls.
Maybe the "proper" way to do this is to have priority levels for the handles?

@twilson63
Copy link
Collaborator

Lets go with prepend for now, and we can look at priorities in the future

@twilson63 twilson63 merged commit f0b3beb into main Oct 29, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants