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

Some thoughts and questions about interface #8

Open
hypesystem opened this issue Jun 15, 2022 · 1 comment
Open

Some thoughts and questions about interface #8

hypesystem opened this issue Jun 15, 2022 · 1 comment

Comments

@hypesystem
Copy link

hypesystem commented Jun 15, 2022

Been thinking a bit about this library, and have some questions.

  • Have you ever used smacker.stop() in a real project?
    I can't think of when I'd want to programatically invoke a process stop and would not just do e.g. process.exit(1)? It seems that the purpose of smacker is handling signals and other unregulated behavior in a nice way, but stopping the process strikes me as out of scope.

  • Could service.start() be made optional?
    What if a service is already "started"? It seems like needless boilerplate to have to provide an empty start method just so things don't break. In some projects, starting will be minimal --- and honestly, in others, the default smacker error handling is fine if something is critically wrong in very first startup...

  • Could we add support for both a Promise-based and callback-based interface for service.start and service.stop?
    This would provide better support for the many legacy systems that do still use callbacks and would have to be promisified.

  • Given these two observations (if smacker.stop is not needed and service.start is optional, and callback based functions are supported), would you consider an interface like this: smacker(service) where service might just have a stop funtion:

    smacker({
      stop: (callback) => server.close(callback),
    });

I for one think that's a pretty neat minimal interface for e.g. express or fastify apps, if there is nothing else to wind down.

@hypesystem
Copy link
Author

hypesystem commented Jun 15, 2022

With innate:

import i from 'innate';

// ...

smacker({ stop: i(server).close });

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

No branches or pull requests

1 participant