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

Approach to implement Hooks #949

Open
simonsan opened this issue Dec 3, 2024 · 0 comments
Open

Approach to implement Hooks #949

simonsan opened this issue Dec 3, 2024 · 0 comments

Comments

@simonsan
Copy link
Contributor

simonsan commented Dec 3, 2024

In terms of abscissa, how would a good implementation for hooks look like. Currently, we are implementing it without really using a lot of abscissa itself, and I would like to understand, if using the framework a better design is possible.

I would contribute that implementation then to the framework. Currently, we are implementing it like this: https://github.com/rustic-rs/rustic/blob/f565eea1f6cb2d9bd9d0f2d324c0d673ccaf7a3a/src/config/hooks.rs

So essentially, we have a Hooks struct that users can define in a configuration (we have global hooks [run application level], repository hooks [run, when accessing a repo], backup hooks [run during backup command lifecycle] backup.snapshots.hooks [run when creating/finishing a snapshot during a backup], src: https://github.com/rustic-rs/rustic/blob/f565eea1f6cb2d9bd9d0f2d324c0d673ccaf7a3a/config/hooks.toml) and execute commands during the application lifecycle.

For this, we essentially call Hooks::use_with(|| -> Result<T> {}) within a command, we also run global hooks inside the Application::after_config method, final hooks we run in Application::shutdown_with_exitcode methods. I think it would be interested, to integrate this functionality a bit deeper in the framework, because it feels like this would give more control over the application's lifecycle and make it easier to integrate.

As the creator of this framework, @tony-iqlusion, is there some insights you could give how to do that better? Would it be more straight forward, to use something like a Component for that, that the commands would be run in, like the abscissa_tokio component essentially?

Or do you think, the scope of this is too wide? Essentially from the most outer scope, begin and end of application, with complete error handling, then on command level and even within a command when accessing certain parts within a custom type?

@simonsan simonsan changed the title Hooks Approach to implement Hooks Dec 3, 2024
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