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

[FEATURE] Add custom hook support #633

Closed
10 tasks
joluj opened this issue Jan 7, 2025 · 1 comment · Fixed by #635
Closed
10 tasks

[FEATURE] Add custom hook support #633

joluj opened this issue Jan 7, 2025 · 1 comment · Fixed by #635
Assignees
Labels
enhancement New feature or request

Comments

@joluj
Copy link
Contributor

joluj commented Jan 7, 2025

User Story

  1. As a {developer that uses the Jayvee lib}
  2. I want {to add custom hooks that run before or after blocks}
  3. So that {I can enrich Jayvee without modifying the original source code}

User Acceptance Criteria

  • Users of the Jayvee lib can add hooks to all blocks
  • Users of the Jayvee lib can add hooks to individual blocks (not in the first version)
  • Users of the Jayvee lib can add hooks to whole pipelines / programs (not in the first version)
  • The number of hooks per blocks is not limited

A hook is basically a function that is called when due.

  • It can be blocking or non-blocking. It's a user's choice. Default: non-blocking
  • It can be asynchronous (important detail for blocking functions).
  • If it's a pre-block hook: It retrieves the input parameters of a block (i.e. metadata and data).
  • If it's a post-block hook: It retrieves the input and output parameters of a block (i.e. metadata and input data and output data).
  • In this first version, there is no option to alter the input or output data or metadata.

Examples

I can imaging that we can use it like that:

const myJayveeProgram = // ...;
myJayveeProgram.addPreBlockHook(async ({args, input}) => {
  console.log(args); // type `unknown`? For now at least
  console.log(input); // type `unknown`? For now at least
}, {
  blocking: true,
});

myJayveeProgram.execute();

Notes

No support is needed for:

  • Removing hooks

Definitions of Done

  • A PR has been opened and accepted
  • All user acceptance criteria are met
  • All tests are passing
@joluj joluj added the enhancement New feature or request label Jan 7, 2025
@joluj
Copy link
Contributor Author

joluj commented Jan 7, 2025

@TungstnBallon This is a first version for the hooks. There is not much options available for this first draft of the hooks, more advanced feature will come in follow up issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants