Skip to content
Merged
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
37 changes: 19 additions & 18 deletions capabilities/coordination/src/testing/test-host.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { freshInstances, machineSandboxOf, sandboxModuleIn, sandboxShippedRoots } from '@on.auto/workflow-engine/dsl';
import { openWorkflowHost, type WorkflowHost } from '@on.auto/workflow-host';
import { recordedReactions, recordedWaiting } from '@on.auto/workflow-host/testing';
import { Effect, Function } from 'effect';
import type { WorkflowHost } from '@on.auto/workflow-host';
import { recordedReactions, recordedWaiting, workflowHostOnALedger } from '@on.auto/workflow-host/testing';
import { Effect } from 'effect';

import { callResultOfEnding, definitionCalls } from '../calls/function-calls.ts';
import { workflowMachineOptionsOf } from '../runs/workflow-machine-options.ts';
Expand All @@ -14,20 +14,21 @@ const sandboxFiles = shippedFilesOnDisk(sandboxShippedRoots);
const sandboxModule = await sandboxModuleIn(sandboxFiles);

export function testHost(nested: Playbook): Promise<WorkflowHost> {
return openWorkflowHost({
database: { store: 'sqlite', file: ':memory:' },
machine: workflowMachineOptionsOf(machineSandboxOf(freshInstances(sandboxModule)), testPlaybookNames),
perform: definitionCalls(nested.executeNested),
settle: nested.settle,
reports: {
unsettled: Effect.logWarning,
trouble: Effect.logWarning,
lostConnection: Function.constVoid,
note: Effect.logWarning,
return workflowHostOnALedger(
{ store: 'sqlite', file: ':memory:' },
{
machine: workflowMachineOptionsOf(machineSandboxOf(freshInstances(sandboxModule)), testPlaybookNames),
perform: definitionCalls(nested.executeNested),
settle: nested.settle,
reports: {
unsettled: Effect.logWarning,
trouble: Effect.logWarning,
note: Effect.logWarning,
},
sweepEveryMs: 20,
mostCallsAtOnce: 4,
reactions: recordedReactions().options,
waiting: { ...recordedWaiting().options, resultOf: callResultOfEnding },
},
sweepEveryMs: 20,
mostCallsAtOnce: 4,
reactions: recordedReactions().options,
waiting: { ...recordedWaiting().options, resultOf: callResultOfEnding },
});
);
}
4 changes: 2 additions & 2 deletions capabilities/prediction/measure/dataset-rebuild.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { setTimeout } from 'node:timers/promises';

import type { FilterSandbox } from '@on.auto/workflow-engine';
import { someFolder, type DatabaseSettings, type HostDatabase } from '@on.auto/workflow-host';
import { projectedFolders, type ProjectedFolders } from '@on.auto/workflow-host/testing';
import { someFolder, type HostDatabase } from '@on.auto/workflow-host';
import { projectedFolders, type DatabaseSettings, type ProjectedFolders } from '@on.auto/workflow-host/testing';
import { Effect } from 'effect';

import { datasetFolder, datasetsOf } from '../src/dataset/dataset-folder.ts';
Expand Down
2 changes: 1 addition & 1 deletion capabilities/prediction/measure/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { join } from 'node:path';
import { plainPoolsOn, postgresqlLedgerLayer } from '@on.auto/ledger/postgresql';
import { ledgerLayer } from '@on.auto/ledger/sqlite3';
import type { Ledger } from '@on.auto/operations';
import type { DatabaseSettings } from '@on.auto/workflow-host';
import type { DatabaseSettings } from '@on.auto/workflow-host/testing';
import type { Layer } from 'effect';
import { Client } from 'pg';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';

import type { DatabaseSettings } from '@on.auto/workflow-host';
import type { DatabaseSettings } from '@on.auto/workflow-host/testing';
import { onTestFinished } from 'vitest';

export type SettingsOf = () => Promise<DatabaseSettings>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { filterSandboxOf, freshInstances, sandboxModuleIn, sandboxShippedRoots } from '@on.auto/workflow-engine/dsl';
import { someFolder, type DatabaseSettings } from '@on.auto/workflow-host';
import { projectedFolders, type ProjectedFolders } from '@on.auto/workflow-host/testing';
import { someFolder } from '@on.auto/workflow-host';
import { projectedFolders, type DatabaseSettings, type ProjectedFolders } from '@on.auto/workflow-host/testing';
import { Effect, Option, Result, type Schema } from 'effect';
import { expect, onTestFinished, vi } from 'vitest';

Expand Down
2 changes: 1 addition & 1 deletion docs/self-host/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ The [engine's README](https://github.com/BeOnAuto/runtime/blob/main/packages/wor
| `An answer of a call could not be recorded; it is written again until it is` | warning | The server keeps writing the call's result |
| `A call could not record its answer` | warning | A call's result was not recorded |
| `An answer of a call could not be given to its run` | warning | A recorded result did not reach its run |
| `A connection of the workflows to their PostgreSQL database was lost; they open another when they need one` | warning | PostgreSQL only; the server reconnects |
| `A connection to the PostgreSQL database of the ledger was lost; the ledger opens another when it needs one` | warning | PostgreSQL only; the workflows share the ledger's connections, and it reconnects |
| `A run could not be settled in <n> attempts; it is tried again once a minute until it is` | warning | The end of the run is retried once a minute; see [Settling a run](#settling-a-run) |
| `A run that could not be settled was settled at attempt <n>` | warning | The end of the run was recorded |
| `A run stays started because settling it failed` | error | `reason` is `The ledger has no such run` or `The run was settled otherwise before` |
Expand Down
Loading