-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip. Try '.init -f example/backpressure-wf.yaml --options={snapshot:{}}' * README++ and bug fixes * lockfiles * README++ * README++ --------- Co-authored-by: Geoffrey Hendrey <[email protected]>
- Loading branch information
1 parent
c94f007
commit dc982e1
Showing
15 changed files
with
571 additions
and
1,189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# producer will be sending some test data | ||
produceParams: | ||
type: "my-topic" | ||
data: ${[1..6].($fetch('https://swapi.dev/api/planets/?page=' & $string($)).json().results)} | ||
client: | ||
type: test | ||
subscribeResidents: | ||
source: cloudEvent | ||
type: /${ produceParams.type } # subscribe to the same topic as we are publishing to test events | ||
to: /${ getResidentsWorkflow } | ||
subscriberId: subscribeResidents | ||
parallelism: 4 | ||
client: | ||
type: test | ||
getResidentsWorkflow: | ||
function: /${ function($planetInfo){ $planetInfo ~> $serial([extractResidents, fetchResidents]) } } | ||
extractResidents: | ||
function: /${ function($planet){$planet.residents.($fetch($).json())} } | ||
fetchResidents: | ||
function: /${ function($resident){$resident?$set('/residents/-',{'name':$resident.name, 'url':$resident.url})} } | ||
residents: [ ] | ||
# starts producer function | ||
send$: $publish(produceParams) | ||
recv$: $subscribe(subscribeResidents) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
start: ${ $millis() } | ||
# producer will be sending some test data | ||
produceParams: | ||
type: "my-topic" | ||
data: ${['luke', 'han', 'leia', 'R2-D2', 'Owen', 'Biggs', 'Obi-Wan', 'Anakin', 'Chewbacca', 'Wedge'].('https://swapi.dev/api/people/?search='&$)} | ||
client: | ||
type: test | ||
# the subscriber's 'to' function will be called on each received event | ||
subscribeParams: #parameters for subscribing to an event | ||
source: cloudEvent | ||
type: /${ produceParams.type } # subscribe to the same topic as we are publishing to test events | ||
to: /${joinResistance} | ||
subscriberId: rebelArmy | ||
initialPosition: latest | ||
parallelism: 1 | ||
client: | ||
type: test | ||
joinResistance: | | ||
/${ | ||
function($url){( | ||
$rebel := $fetch($url).json().results[0].name; | ||
$set( "/rebelForces/-", $rebel) /* append rebel to rebelForces */ | ||
)} | ||
} | ||
# starts producer function | ||
send$: $publish(produceParams) | ||
# starts consumer function | ||
recv$: $subscribe(subscribeParams) | ||
# the subscriber's `to` function will write the received data here | ||
rebelForces: [ ] | ||
runtime: ${ (rebelForces; "Rebel forces assembled in " & $string($millis()-start) & " ms")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
start: ${ $millis() } | ||
# producer will be sending some test data | ||
produceParams: | ||
type: "my-topic" | ||
data: ${['luke', 'han', 'leia', 'R2-D2', 'Owen', 'Biggs', 'Obi-Wan', 'Anakin', 'Chewbacca', 'Wedge'].('https://swapi.dev/api/people/?search='&$)} | ||
client: | ||
type: test | ||
# the subscriber's 'to' function will be called on each received event | ||
subscribeParams: #parameters for subscribing to an event | ||
source: cloudEvent | ||
type: /${ produceParams.type } # subscribe to the same topic as we are publishing to test events | ||
to: /${joinResistance} | ||
subscriberId: rebelArmy | ||
initialPosition: latest | ||
parallelism: 5 | ||
client: | ||
type: test | ||
joinResistance: | | ||
/${ | ||
function($url){( | ||
$rebel := $fetch($url).json().results[0].name; | ||
$set( "/rebelForces", $rebelForces~>$append($rebel)) /* BUG!! */ | ||
)} | ||
} | ||
# starts producer function | ||
send$: $publish(produceParams) | ||
# starts consumer function | ||
recv$: $subscribe(subscribeParams) | ||
# the subscriber's `to` function will write the received data here | ||
rebelForces: [ ] | ||
runtime: ${ (rebelForces; "Rebel forces assembled in " & $string($millis()-start) & " ms")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
start: ${ $millis() } | ||
# producer will be sending some test data | ||
produceParams: | ||
type: "my-topic" | ||
data: ${['luke', 'han', 'leia', 'R2-D2', 'Owen', 'Biggs', 'Obi-Wan', 'Anakin', 'Chewbacca', 'Wedge'].('https://swapi.dev/api/people/?search='&$)} | ||
client: | ||
type: test | ||
# the subscriber's 'to' function will be called on each received event | ||
subscribeParams: #parameters for subscribing to an event | ||
source: cloudEvent | ||
type: /${ produceParams.type } # subscribe to the same topic as we are publishing to test events | ||
to: /${joinResistance} | ||
subscriberId: rebelArmy | ||
initialPosition: latest | ||
parallelism: 5 | ||
client: | ||
type: test | ||
joinResistance: | | ||
/${ | ||
function($url){( | ||
$rebel := $fetch($url).json().results[0].name; | ||
$set( "/rebelForces/-", $rebel) /* append rebel to rebelForces */ | ||
)} | ||
} | ||
# starts producer function | ||
send$: $publish(produceParams) | ||
# starts consumer function | ||
recv$: $subscribe(subscribeParams) | ||
# the subscriber's `to` function will write the received data here | ||
rebelForces: [ ] | ||
runtime: ${ (rebelForces; "Rebel forces assembled in " & $string($millis()-start) & " ms")} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { promises as fs } from 'fs'; | ||
|
||
export class Snapshot { | ||
|
||
static async write(tp) { | ||
const {snapshot: snapshotOpts} = tp.options; | ||
if(!snapshotOpts){ | ||
tp.logger.debug("no --snapshot options defined, skipping snapshot"); | ||
return; | ||
} | ||
const snapshotStr = tp.snapshot(); | ||
const {storage = "fs", path = "./defaultSnapshot.json"} = snapshotOpts; // Default path if not provided | ||
|
||
if (storage === "fs") { | ||
try { | ||
await fs.writeFile(path, snapshotStr); | ||
tp.logger.info(`Snapshot saved to ${path}`); | ||
} catch (error) { | ||
console.error(`Failed to save snapshot to ${path}:`, error); | ||
throw error; | ||
} | ||
} else { | ||
tp.logger.info('Storage method not supported.'); | ||
} | ||
} | ||
} |
Oops, something went wrong.