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

Featurea/allow skipping running actions on startup #10

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core-persistence/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-core-persistence",
"version": "0.0.37",
"version": "0.0.38",
"description": "XJog chart abstract persistence",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,7 +29,7 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-util": "^0.0.33",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core-pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-core-pg",
"version": "0.0.61",
"version": "0.0.62",
"description": "XJog chart Postgres persistence",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,8 +29,8 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-core-persistence": "^0.0.37",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-core-persistence": "^0.0.38",
"@samihult/xjog-util": "^0.0.33",
"node-pg-migrate": "^6.2.1",
"pg": "^8.7.3",
"pg-bind": "^1.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog",
"version": "0.0.315",
"version": "0.0.316",
"description": "XState chart runner for long-running charts",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -30,8 +30,8 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-core-persistence": "^0.0.37",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-core-persistence": "^0.0.38",
"@samihult/xjog-util": "^0.0.33",
"async-mutex": "^0.3.2",
"rxjs": "^7.4.0",
"uuid": "^8.3.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/XJogOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export type XJogOptions = {
adoptionFrequency?: number;
/** How long to wait until forcibly adopt old instance's charts. */
gracePeriod?: number;
/**
* If set to true, XJog will not run actions when rehydrating. If set to
* false then only init actions are not run.
* Defaults to false.
*/
skipRunningActionsOnRehydrate?: boolean;
};
deferredEvents?: {
/** Number of deferred events to process at a time */
Expand All @@ -42,6 +48,7 @@ export type ResolvedXJogOptions = {
startup: {
adoptionFrequency: number;
gracePeriod: number;
skipRunningActionsOnRehydrate: boolean;
};
deferredEvents: {
batchSize: number;
Expand Down Expand Up @@ -102,9 +109,13 @@ export function resolveXJogStartupOptions(
trace,
);

const skipRunningActionsOnRehydrate =
options?.skipRunningActionsOnRehydrate ?? false;

return {
adoptionFrequency,
gracePeriod,
skipRunningActionsOnRehydrate,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/XJogStartupManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ export class XJogStartupManager {
refs: ChartReference[],
cid = getCorrelationIdentifier(),
): Promise<void> {
const skipOnRehydrate =
this.xJog.options.startup.skipRunningActionsOnRehydrate;
if (skipOnRehydrate) {
return;
}
for (const ref of refs) {
const adoptedChart = await this.xJog.getChart(ref, cid);
await adoptedChart?.runStep(cid);
Expand Down
4 changes: 2 additions & 2 deletions packages/digest-persistence/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-digest-persistence",
"version": "0.0.23",
"version": "0.0.24",
"description": "XJog chart digest persistence adapter",
"engines": {
"npm": ">=8.19.4",
Expand All @@ -27,7 +27,7 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-util": "^0.0.33",
"rxjs": "^7.4.0"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/digest-pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-digest-pg",
"version": "0.0.116",
"version": "0.0.117",
"description": "XJog Postgres digest persistence",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,8 +29,8 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-digest-persistence": "^0.0.23",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-digest-persistence": "^0.0.24",
"@samihult/xjog-util": "^0.0.33",
"node-pg-migrate": "^6.2.1",
"pg": "^8.7.3",
"pg-bind": "^1.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/digest-reader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-digest-reader",
"version": "0.0.28",
"version": "0.0.29",
"description": "XJog chart digest reader",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,8 +29,8 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-digest-persistence": "^0.0.23",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-digest-persistence": "^0.0.24",
"@samihult/xjog-util": "^0.0.33",
"rxjs": "^7.4.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/digest-writer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-digest-writer",
"version": "0.0.15",
"version": "0.0.16",
"description": "XJog chart digest writer",
"engines": {
"npm": ">=8.19.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/journal-persistence/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-journal-persistence",
"version": "0.0.51",
"version": "0.0.52",
"description": "XJog chart abstract journal persistence adapter",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,7 +29,7 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-util": "^0.0.33",
"rfc6902": "^5.0.1",
"rxjs": "^7.4.0",
"uuid": "^8.3.2"
Expand Down
8 changes: 4 additions & 4 deletions packages/journal-pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-journal-pg",
"version": "0.0.115",
"version": "0.0.116",
"description": "XJog Postgres journaling persistence",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,9 +29,9 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog-core-persistence": "^0.0.37",
"@samihult/xjog-journal-persistence": "^0.0.51",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog-core-persistence": "^0.0.38",
"@samihult/xjog-journal-persistence": "^0.0.52",
"@samihult/xjog-util": "^0.0.33",
"node-pg-migrate": "^6.2.1",
"pg": "^8.7.3",
"pg-bind": "^1.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/journal-reader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-journal-reader",
"version": "0.0.53",
"version": "0.0.54",
"description": "XJog chart journal reader",
"engines": {
"npm": ">=8.19.4",
Expand Down Expand Up @@ -29,8 +29,8 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog": "^0.0.315",
"@samihult/xjog-util": "^0.0.32",
"@samihult/xjog": "^0.0.316",
"@samihult/xjog-util": "^0.0.33",
"pg": "^8.7.3",
"pg-bind": "^1.0.1",
"pg-listen": "^1.7.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/journal-writer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-journal-writer",
"version": "0.0.69",
"version": "0.0.70",
"description": "XJog chart journal writer",
"engines": {
"npm": ">=8.19.4",
Expand All @@ -27,9 +27,9 @@
"clean": "rm -rf node_modules lib"
},
"dependencies": {
"@samihult/xjog": "^0.0.315",
"@samihult/xjog-journal-persistence": "^0.0.51",
"@samihult/xjog-util": "^0.0.32"
"@samihult/xjog": "^0.0.316",
"@samihult/xjog-journal-persistence": "^0.0.52",
"@samihult/xjog-util": "^0.0.33"
},
"devDependencies": {
"@types/jest": "^27.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samihult/xjog-util",
"version": "0.0.32",
"version": "0.0.33",
"description": "XJog utils",
"engines": {
"npm": ">=8.19.4",
Expand Down