firepear / petrel

It's like SQLite, but for networking
MIT License
20 stars 1 forks source link

Don't make the user write two loops and handle sigs #63

Open firepear opened 2 years ago

firepear commented 2 years ago

Currently, the user has to write two driver loops for a petrel server:

This was originally done in the name of maximum flexibility, but in reality it's just boilerplate.

At the least, the keepalive loop should be handled internally and provided for free. This would include also handling SIGINT and SIGTERM. There does still need to be a way to notify the app code that petrel has errored or is shutting down -- sounds like a job for another channel, maybe, after internal housekeeping is handled?

It would be great to give users a way to not have to write the message handling loop either. Maybe if that were refactored from a function that wraps a select to an internal select that uses a dispatch table for event handling?

That way the user could register petrel event handlers the same way they register app message handlers?

firepear commented 1 year ago

sig handling has moved into petrel.

refactoring of event loops remains.