Skip to content

Commit

Permalink
Merge pull request #346 from vmware/feature/340-canvas-item-default-e…
Browse files Browse the repository at this point in the history
…rror-handler

[vrotsc, vrotsc-annotations] (#339) Added a new canvas item for Default Error Handler
  • Loading branch information
akantchev authored Jul 22, 2024
2 parents 356aa9f + c9b453b commit 2c96994
Show file tree
Hide file tree
Showing 26 changed files with 465 additions and 20 deletions.
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
}
}
5 changes: 4 additions & 1 deletion typescript/vrotsc/e2e/cases/canvas-items/decision-edge.wf.ts
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
}
}
6 changes: 5 additions & 1 deletion typescript/vrotsc/e2e/cases/canvas-items/root-when-set.wf.ts
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

0 comments on commit 2c96994

Please sign in to comment.