-
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.
Merge pull request #3 from xcherryio/xcherry2
fix missing file changes for changing to xCherry
- Loading branch information
Showing
13 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {RetryPolicy} from 'xcherry-ts-api' | ||
import {Context} from "./context"; | ||
import {Persistence} from "./persistence"; | ||
import {Communication} from "./communication"; | ||
import {StateDecision} from "./state-decision"; | ||
import {CommandRequest} from "./command-request"; | ||
|
||
export interface AsyncState<Input> { | ||
// stateId is a required field to identify the state definition | ||
// It must be unique in all the states in the same process definition. | ||
// It's recommended to just use the Class name of the state as the stateId. | ||
stateId: string | ||
// asyncStateOptions is the options for the async state | ||
stateOptions?: AsyncStateOptions | ||
// waitUntil is the optional method to implement the waitUntil API call. | ||
// waitUntil API will return a commandRequest for server to wait for. | ||
// After the commandRequest is completed, the execute API will be invoked. | ||
// if waitUntil is not implemented, the execute API will be invoked immediately. | ||
waitUntil?: WaitUntilMethod<Input> | ||
|
||
// execute is the required method to implement the execute API call. | ||
execute(ctx: Context, input: Input, persistence: Persistence, communication: Communication): StateDecision | ||
} | ||
|
||
export interface WaitUntilMethod<Input> { | ||
waitUntil(ctx: Context, input: Input, communication: Communication): CommandRequest | ||
} | ||
|
||
export interface AsyncStateOptions { | ||
// waitUntilTimeoutSeconds is the timeout for the waitUntil API call. | ||
// Default: 10 seconds(configurable in server) when set as 0 | ||
// It will be capped to 60 seconds by server (configurable in server) | ||
waitUntilTimeoutSeconds?: number | ||
// executeTimeoutSeconds is the timeout for the execute API call. | ||
// Default: 10 seconds(configurable in server) when set as 0 | ||
// It will be capped to 60 seconds by server (configurable in server) | ||
executeTimeoutSeconds?: number | ||
// waitUntilRetryPolicy is the retry policy for the waitUntil API call. | ||
// Default: infinite retry with 1 second initial interval, 120 seconds max interval, and 2 backoff factor, | ||
// when set as nil | ||
waitUntilRetryPolicy?: RetryPolicy | ||
// executeRetryPolicy is the retry policy for the execute API call. | ||
// Default: infinite retry with 1 second initial interval, 120 seconds max interval, and 2 backoff factor, | ||
// when set as nil | ||
executeRetryPolicy?: RetryPolicy | ||
// failureRecoveryState is the state to recover after current state execution fails | ||
// Default: no recovery when set as nil | ||
failureRecoveryState?: AsyncState<any> | ||
// persistencePolicyName is the name of loading policy for persistence if not using default policy | ||
persistencePolicyName?: string | ||
} |
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,3 @@ | ||
export interface CommandRequest { | ||
// TODO | ||
} |
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,3 @@ | ||
export interface Communication { | ||
// TODO | ||
} |
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,3 @@ | ||
export interface Context { | ||
// TODO | ||
} |
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,3 @@ | ||
export interface PersistenceSchema { | ||
// TODO | ||
} |
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,3 @@ | ||
export interface Persistence { | ||
// TODO | ||
} |
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 @@ | ||
import {StateSchema} from "./state-schema"; | ||
import {PersistenceSchema} from "./persistence-schema"; | ||
import {ProcessIdReusePolicy} from "xcherry-ts-api"; | ||
|
||
export interface Process { | ||
// processType is a required field to identify the process type. | ||
// It must be unique in all the processes registered in the same registry. | ||
// It's recommended to just use the Class name of the process as the processType. | ||
processType: string | ||
// stateSchema is to define the async states of the process. | ||
stateSchema?: StateSchema | ||
// persistenceSchema is to define the persistence schema of the process. | ||
persistenceSchema?: PersistenceSchema | ||
// processOptions is the options for the process | ||
processOptions?: ProcessOptions | ||
} | ||
|
||
export interface ProcessOptions { | ||
// TimeoutSeconds is the timeout for the process execution. | ||
// Default: 0, mean which means infinite timeout | ||
timeoutSeconds?: number | ||
// IdReusePolicy is the policy for reusing process id. | ||
// Default: xdbapi.ALLOW_IF_NO_RUNNING when set as nil | ||
idReusePolicy?: ProcessIdReusePolicy | ||
} |
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,3 @@ | ||
export interface StateDecision { | ||
// TODO | ||
} |
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,30 @@ | ||
import {AsyncState} from "./async-state"; | ||
|
||
export interface StateSchema { | ||
startingState: AsyncState<any> | null | undefined | ||
nonStartingStates: AsyncState<any>[] | ||
} | ||
|
||
export function newStateSchema( | ||
startingState: AsyncState<any>, | ||
...nonStartingState: AsyncState<any>[] | ||
): StateSchema { | ||
return new stateSchema(startingState, ...nonStartingState); | ||
} | ||
|
||
export function newStateSchemaNoStartingState( | ||
...nonStartingState: AsyncState<any>[] | ||
): StateSchema { | ||
return new stateSchema(null, ...nonStartingState); | ||
} | ||
|
||
class stateSchema implements StateSchema { | ||
nonStartingStates: AsyncState<any>[]; | ||
startingState: AsyncState<any> | null | undefined; | ||
|
||
constructor(startingState: AsyncState<any> | null, ...nonStartingState: AsyncState<any>[]) { | ||
this.nonStartingStates = nonStartingState; | ||
this.startingState = startingState; | ||
} | ||
} | ||
|