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

[vrotsc, vrotsc-annotations] (#339) Add Workflow canvas Default Error Handler item #346

Merged
merged 7 commits into from
Jul 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,82 @@ How to use Aria Orchestrator Workflows and available decorators.
- [`@WaitingTimerItem`](#waitingtimeritem)
- [`@DecisionItem`](#decisionitem)
- [`@RootItem`](#rootitem)
- [`@DefaultErrorHandler`](#defaulterrorhandler)
- [`@WorkflowEndItem`](#workflowenditem)
3. [Example Workflow](#example-workflow)

### Workflow Decorator

Not implemented yet.

#### `@DefaultErrorHandler`

This decorator is used to specify a default error handler. It can be bound either to a workflow item component or workflow end.

#### Supported Parameters

- `target` - target item to be attached to the default error handler, could be one of workflow item or workflow end.
- `exceptionVariable` - Exception variable that will hold the exception data when triggered.

In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items.

Example:

```typescript
import {
Workflow,
RootItem,
In,
Out,
Item,
DefaultErrorHandler,
WorkflowEndItem,
} from "vrotsc-annotations";

@Workflow({
name: "Default Error Handler Custom Item",
path: "VMware/PSCoE",
description:
"Default error handler workflow with error handler redirecting to a workflow item",
attributes: {
errorMessage: {
type: "string",
},
},
})
export class HandleDefaultError {
@RootItem()
public initiateWorkflow() {
System.log("Initiating workflow execution");
}

@Item({
target: "workflowEnd",
})
public processError(@In errorMessage: string) {
System.log(
`Processing error using custom task with message '${errorMessage}'`
);
}

@DefaultErrorHandler({
exceptionVariable: "errorMessage",
target: "processError",
})
public defaultErrorHandler(@Out errorMessage: string) {
// NOOP
}

@WorkflowEndItem({
endMode: 0,
exceptionVariable: "errorMessage",
})
public workflowEnd(@Out errorMessage: string) {
System.log(`Terminating workflow with error ${errorMessage}`);
}
}
```

### Available Method Decorators

#### `@WorkflowEndItem`
Expand Down Expand Up @@ -172,7 +241,7 @@ export class HandleNetworkConfigurationBackup {
@WorkflowEndItem({
endMode: 0,
exception: "errorMessage",
businessStatus: "Bad"
businessStatus: "Bad",
})
public workflowEnd() {
// NOOP
Expand Down
68 changes: 68 additions & 0 deletions docs/versions/latest/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,74 @@
[//]: # "#### Relevant Documentation:"
[//]: # "Improvements -> Bugfixes/hotfixes or general improvements"

### \*New `DefaultErrorHandler` decorator for Workflows

This decorator is used to specify a default error handler. It can be bound either to a workflow item component or workflow end.

#### Supported Parameters

- `target` - target item to be attached to the default error handler, could be one of workflow item or workflow end.
- `exceptionVariable` - Exception variable that will hold the exception data when triggered.

In order to bind inputs and outputs, you do it with the `@In` and `@Out` decorators. This is the same way we do it for other items.

Example:

```typescript
import {
Workflow,
RootItem,
In,
Out,
Item,
DefaultErrorHandler,
WorkflowEndItem,
} from "vrotsc-annotations";

@Workflow({
name: "Default Error Handler Custom Item",
path: "VMware/PSCoE",
description:
"Default error handler workflow with error handler redirecting to a workflow item",
attributes: {
errorMessage: {
type: "string",
},
},
})
export class HandleDefaultError {
@RootItem()
public initiateWorkflow() {
System.log("Initiating workflow execution");
}

@Item({
target: "workflowEnd",
})
public processError(@In errorMessage: string) {
System.log(
`Processing error using custom task with message '${errorMessage}'`
);
}

@DefaultErrorHandler({
exceptionVariable: "errorMessage",
target: "processError",
})
public defaultErrorHandler(@Out errorMessage: string) {
// NOOP
}

@WorkflowEndItem({
endMode: 0,
exceptionVariable: "errorMessage",
})
public workflowEnd(@Out errorMessage: string) {
System.log(`Terminating workflow with error ${errorMessage}`);
}
}
```

### \*New `@WorkflowEndItem` decorator for Workflows

The decorator is used to specify a custom workflow end item.
Expand Down
2 changes: 2 additions & 0 deletions typescript/vrotsc/e2e/cases/canvas-items/complex.wf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem } fro
}
})
export class Complex {

@DecisionItem({
target: "waitForEvent",
else: null
Expand Down Expand Up @@ -59,5 +60,6 @@ export class Complex {
target: "execute"
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({})
public decisionElement(waitingTimer: Date) {
return waitingTimer !== null;
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({
target: "waitForEvent",
})
public decisionElement(waitingTimer: Date) {
return waitingTimer !== null;
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Workflow, DecisionItem } from "vrotsc-annotations";
}
})
export class HandleNetworkConfigurationBackup {

@DecisionItem({
target: "shouldGoHere",
else: "end"
Expand All @@ -20,5 +21,7 @@ export class HandleNetworkConfigurationBackup {
}

// This will point to end too, but no incoming
public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Workflow, RootItem, In, Out, Item, DefaultErrorHandler, WorkflowEndItem } from "vrotsc-annotations";

@Workflow({
name: "Default Error Handler Custom Item",
path: "VMware/PSCoE",
description: "Default error handler workflow with error handler redirecting to a workflow item",
attributes: {
errorMessage: {
type: "string"
}
}
})
export class HandleDefaultError {

@RootItem()
public initiateWorkflow() {
System.log("Initiating workflow execution");
}

@Item({
target: "workflowEnd"
})
public processError(@In errorMessage: string) {
System.log(`Processing error using custom task with message '${errorMessage}'`);
}

@DefaultErrorHandler({
exceptionVariable: "errorMessage",
target: "processError"
})
public defaultErrorHandler(@Out errorMessage: string) {
// NOOP
}

@WorkflowEndItem({
endMode: 0,
exceptionVariable: "errorMessage",
})
public workflowEnd(@Out errorMessage: string) {
System.log(`Terminating workflow with error ${errorMessage}`);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Workflow, RootItem, DefaultErrorHandler } from "vrotsc-annotations";

@Workflow({
name: "Default Error Handler Happy",
path: "VMware/PSCoE",
description: "Default error handler workflow",
attributes: {
errorMessage: {
type: "string"
}
}
})
export class HandleDefaultError {

@RootItem()
public initiateWorkflow() {
// NOOP
}

@DefaultErrorHandler({
exceptionVariable: "errorMessage",
target: "end"
})
public defaultErrorHandler() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import { Workflow, In, Item } from "vrotsc-annotations";
}
})
export class Complex {

@Item({
target: "end"
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

public shouldNotGoHere() { }
public shouldNotGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ import { Workflow, In, Item, RootItem } from "vrotsc-annotations";
}
})
export class Complex {

@Item({
target: "end"
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

@RootItem()
public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ import { Workflow, In, WaitingTimerItem } from "vrotsc-annotations";
}
})
export class Complex {

@WaitingTimerItem({})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import { Workflow, In, WaitingTimerItem } from "vrotsc-annotations";
}
})
export class Complex {

@WaitingTimerItem({
target: "shouldGoHere",
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

public shoulNotdGoHere() { }
public shouldNotGoHere() {
// NOOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import { Workflow, In, WaitingTimerItem } from "vrotsc-annotations";
}
})
export class Complex {

@WaitingTimerItem({
target: "shouldGoHere"
})
public waitForEvent(@In waitingTimer: Date) {
// NOOP
}

public shouldGoHere() { }
public shouldGoHere() {
// NOOP
}
}
Loading
Loading