OpenFn / OpenFn/kit

Runtime lifecycle APIs

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design
Dominant language
TypeScript
Stars
21
Forks
23
Avg merge
1d 22h
Merged PRs (30d)
17

Description

Just thinking ahead a little.

The runtime should provide lifecycle hooks which can be imported by adaptors (and jobs, why not).

Ie, language-postgres will want to do this:

import { onStart, onEnd } from '@openfn/runtime

onStart(() => connect(state.data.configuration) );
onEnd(() => tearDown());

This is a sketch of the interface:

// Run a function when the pipeline starts (a pre or init step)
export onStart(fn(state: any) => state): void;

// Run a function when the pipeline ends (a post or final step)
export onStart(fn(state: any) => state): void;

// Run a function before each job
// Maybe not useful for adaptors but probably useful for runtime managers!
// Maybe this should take the operation, or some metadata about it, as an argument
export beforeEach(fn(state: any) => state): void;

export afterEach(fn(state: any) => state): void;

Do we want the API to be registerCallback or onEvent or hooks.onStart ?

Do we want pre and post semantics instead of start and end?

An alternative API would be like:

type HookStage = 'start' | 'end' | 'beforeEach' | 'afterEach'

addHook(when: HookStage, fn: Operation)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests. Start by locating the runtime entry points used by adaptors and jobs, then resolve the proposed start, end, beforeEach, and afterEach semantics and API shape; done means an agreed lifecycle-hook interface with coverage for its behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.