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

v2: Rework hooks system #516

Merged
merged 16 commits into from
Mar 1, 2022
Merged

v2: Rework hooks system #516

merged 16 commits into from
Mar 1, 2022

Conversation

Acconut
Copy link
Member

@Acconut Acconut commented Oct 19, 2021

This branch is used to develop the new hook system. The main concepts will stay the same (i.e. file, HTTP, gRPC hooks) but the exact interface has to change.

Goals:

  • Experiment with new plugins using https://github.com/hashicorp/go-plugin
  • Allow hooks to control status code, headers and body of response (only for pre-* hooks and post-receive hook)
  • Make error responses the exception and not the norm (errors should not be used to reject uploads anymore)
  • Allow additional response values from hooks (e.g. whether upload should be rejected or stopped)

TODO (will be addressed after merge):

  • docs: Update documentation about hooks
  • docs: Add plugin hooks to documentation
  • cli: Consider moving hooks in pkg/
  • cli: Add tests for hook implementations and system
  • handler: Allow modifying the HTTP response when stopping an upload
  • grpc: Add headers to hook request
  • grpc: Add documentation to proto files
  • grpc: Move proto file into better, public location
  • plugin: Stop zombie processes when tusd terminates
  • plugin: Move into public package. The plugin should not import for the cmd directory
  • plugin: Clean up hooks/plugin.go

@Acconut Acconut added enhancement breaking change Backwards compatibility breaking change labels Oct 19, 2021
@Acconut Acconut self-assigned this Oct 19, 2021
@Acconut Acconut mentioned this pull request Oct 29, 2021
@sagikazarmark
Copy link
Contributor

Have you considered only supporting go-plugins for hooks and implementing http, grpc and file hooks as plugin implementations? It would simplify the code you have to maintain in tusd. Granted, it would also introduce a slight performance hit.

@Acconut
Copy link
Member Author

Acconut commented Jan 16, 2022

Have you considered only supporting go-plugins for hooks and implementing http, grpc and file hooks as plugin implementations?

Yes, but it's a tradeoff. I doubt it would reduce code complexity as every hook implementation would need the code for the go-plugin setup. Furthermore, it would make tusd not a single, all-containing binary anymore as users need to ensure that the plugin files are present during runtime.

@Acconut Acconut mentioned this pull request Feb 26, 2022
@Acconut Acconut marked this pull request as ready for review March 1, 2022 23:34
@Acconut Acconut merged commit 12c10bf into v2 Mar 1, 2022
@Acconut Acconut deleted the feat/new-hooks branch June 20, 2023 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Backwards compatibility breaking change enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants