Skip to content

Commit

Permalink
sketch for how data pipelining and fetching from an
Browse files Browse the repository at this point in the history
API works
  • Loading branch information
panzerstadt committed Nov 29, 2023
1 parent c595992 commit 185efd2
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
9 changes: 9 additions & 0 deletions programs/dagdog/POC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## todos

i already have a turing complete synchronous language

what i need to make this testable is:

- anytime global return is sent, we find the next function in the chain and send the data to it (as string for now)
- anytime there is an async task (e.g. the dummyasync ffi), block the function
- execute the code as a file instead of a repl, i'm getting tired of copy pasting to often for testing XD
75 changes: 75 additions & 0 deletions programs/dagdog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,78 @@ start -> functionB, functionD -> functionA
```

internally, it could even compile down to statecharts (a la xstate)

## data pipelining with db queries (natural habitat for dag workflows)

```
collector() -> receiver() -> transformer()* -> dbFetch(), resultTransformer() -> store()
dbFetch() -> resultTransformer
```

```
collector() {
// gets data
return data
}
receiver(incomingData) {
return data
}
transformer(data) {
const transformPayloadToDB = { }
const metadataForResult = { }
return { transformPayloadToDB, metadataForResult }
}
// async db fetch
dbFetch(transformPayload) {
}
resultTransformer({ dbResult, metadata }) {
// post process
return result
}
// long running store process
store() {
}
```

## fetching from an api for a page

```
frontPage() -> handleFetch() -> api() -> postFetch() -> view()
frontPage() -> view()
```

```
frontPage() {
const displayHTML = "<div>hello, <button onClick={() => handleFetch({ query: "foo" })}>click me</div></div>"
return { displayHTML, handleFetch }
}
view({ html, htmlResult }) {
// shows html on screen
return `${html} ${htmlResult}`
}
handleFetch({ query }) {
// does some transformation
return { metadata, apiPayload }
}
api(payload) {
// do something
return res.status(200).json({ message: "ho" })
}
postFetch({ metadata, apiPayload }) {
const message = apiPayload.message
const htmlResult = "<div>you clicked me!</div>"
return htmlResult
}
```

0 comments on commit 185efd2

Please sign in to comment.