-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
WIP DO NOT MERGE StepFunctions Dynamic Parallelism #4153
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import cdk = require('@aws-cdk/core'); | ||
import { Chain } from '../chain'; | ||
import { StateGraph } from '../state-graph'; | ||
import { CatchProps, IChainable, INextable, RetryProps } from '../types'; | ||
import { StateType } from './private/state-type'; | ||
import { renderJsonPath, State } from './state'; | ||
|
||
/** | ||
* Properties for defining a Map state | ||
*/ | ||
export interface MapProps { | ||
/** | ||
* An optional description for this state | ||
* | ||
* @default No comment | ||
*/ | ||
readonly comment?: string; | ||
|
||
/** | ||
* JSONPath expression to select part of the state to be the input to this state. | ||
* | ||
* May also be the special value DISCARD, which will cause the effective | ||
* input to be the empty object {}. | ||
* | ||
* @default $ | ||
*/ | ||
readonly inputPath?: string; | ||
|
||
/** | ||
* JSONPath expression to select part of the state to be the output to this state. | ||
* | ||
* May also be the special value DISCARD, which will cause the effective | ||
* output to be the empty object {}. | ||
* | ||
* @default $ | ||
*/ | ||
readonly outputPath?: string; | ||
|
||
/** | ||
* JSONPath expression to indicate where to inject the state's output | ||
* | ||
* May also be the special value DISCARD, which will cause the state's | ||
* input to become its output. | ||
* | ||
* @default $ | ||
*/ | ||
readonly resultPath?: string; | ||
|
||
/** | ||
* The “MaxConcurrency” field’s value is an integer that provides an | ||
* upper bound on how many invocations of the Iterator may run in parallel. | ||
* | ||
* @default 0 | ||
*/ | ||
readonly maxConcurrency?: number; | ||
} | ||
|
||
/** | ||
* Define a Map state in the state machine | ||
* | ||
* A Map state can be used to run one or more state machines at the same | ||
* time. | ||
* | ||
* The Result of a Map state is an array of the results of its substatemachines. | ||
*/ | ||
export class Map extends State implements INextable { | ||
public readonly endStates: INextable[]; | ||
|
||
/** | ||
* Usually, State Properties are contained in the state.ts file, but maxConcurrency | ||
* only exists in this one state (for now). | ||
*/ | ||
protected readonly maxConcurrency: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: MapProps = {}) { | ||
super(scope, id, props); | ||
|
||
this.endStates = [this]; | ||
} | ||
|
||
/** | ||
* Add retry configuration for this state | ||
* | ||
* This controls if and how the execution will be retried if a particular | ||
* error occurs. | ||
*/ | ||
public addRetry(props: RetryProps = {}): Map { | ||
super._addRetry(props); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add a recovery handler for this state | ||
* | ||
* When a particular error occurs, execution will continue at the error | ||
* handler instead of failing the state machine execution. | ||
*/ | ||
public addCatch(handler: IChainable, props: CatchProps = {}): Map { | ||
super._addCatch(handler.startState, props); | ||
return this; | ||
} | ||
|
||
/** | ||
* Continue normal execution with the given state | ||
*/ | ||
public next(next: IChainable): Chain { | ||
super.makeNext(next.startState); | ||
return Chain.sequence(this, next); | ||
} | ||
|
||
/** | ||
* Define one or more graphs to run in map | ||
*/ | ||
public dynamicBranch(graph: IChainable): Map { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we call it |
||
const name = `Dynamic Map '${this.stateId}'`; | ||
super.addDynamicBranch(new StateGraph(graph.startState, name)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Return the Amazon States Language object for this state | ||
*/ | ||
public toStateJson(): object { | ||
return { | ||
Type: StateType.MAP, | ||
Comment: this.comment, | ||
ResultPath: renderJsonPath(this.resultPath), | ||
MaxConcurrency: this.maxConcurrency, | ||
...this.renderNextEnd(), | ||
...this.renderInputOutput(), | ||
...this.renderRetryCatch(), | ||
...this.renderDynamicMap(), | ||
}; | ||
} | ||
|
||
/** | ||
* Validate this state | ||
*/ | ||
protected validate(): string[] { | ||
if (this.branches.length === 0) { | ||
return ['Map must have at least one branch']; | ||
} | ||
return []; | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not get set, does it?