Rename Choice to Parallel and cases to branches (#1786)

This commit is contained in:
Lionel Villard 2019-09-16 15:37:42 -04:00 committed by Knative Prow Robot
parent 533e6b7bf3
commit 6e8388eb2a
19 changed files with 95 additions and 94 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
.idea/
.vscode/
.history/

View File

@ -1,45 +0,0 @@
---
title: "Choice"
weight: 20
type: "docs"
---
Choice CRD provides a way to easily define a list of branches, each receiving
the same CloudEvent sent to the Choice ingress channel. Typically, each branch
consists of a filter function guarding the execution of the branch.
Choice creates `Channel`s and `Subscription`s under the hood.
## Usage
### Choice Spec
Choice has three parts for the Spec:
1. `cases` defines the list of `filter` and `subscriber` pairs, one per branch,
and optionally a `reply` object. For each branch:
1. the `filter` is evaluated and when it returns an event the `subscriber` is
executed. Both `filter` and `subscriber` must be `Callable`.
1. the event returned by the `subscriber` is sent to the branch `reply`
object. When the `reply` is empty, the event is sent to the `spec.reply`
object (see below).
1. (optional) `channelTemplate` defines the Template which will be used to
create `Channel`s.
1. (optional) `reply` defines where the result of each branch is sent to when
the branch does not have its own `reply` object.
### Choice Status
Choice has three parts for the Status:
1. `conditions` which details the overall status of the Choice object
1. `ingressChannelStatus` and `caseStatuses` which convey the status of
underlying `Channel` and `Subscription` resource that are created as part of
this Choice.
1. `address` which is exposed so that Choice can be used where Addressable can
be used. Sending to this address will target the `Channel` which is fronting
this Choice (same as `ingressChannelStatus`).
## Examples
Learn how to use Choice by following the [examples](./samples/choice/README.md)

45
docs/eventing/parallel.md Normal file
View File

@ -0,0 +1,45 @@
---
title: "Parallel"
weight: 20
type: "docs"
---
Parallel CRD provides a way to easily define a list of branches, each receiving
the same CloudEvent sent to the Parallel ingress channel. Typically, each branch
consists of a filter function guarding the execution of the branch.
Parallel creates `Channel`s and `Subscription`s under the hood.
## Usage
### Parallel Spec
Parallel has three parts for the Spec:
1. `branches` defines the list of `filter` and `subscriber` pairs, one per branch,
and optionally a `reply` object. For each branch:
1. (optional) the `filter` is evaluated and when it returns an event the `subscriber` is
executed. Both `filter` and `subscriber` must be `Callable`.
1. the event returned by the `subscriber` is sent to the branch `reply`
object. When the `reply` is empty, the event is sent to the `spec.reply`
object (see below).
1. (optional) `channelTemplate` defines the Template which will be used to
create `Channel`s.
1. (optional) `reply` defines where the result of each branch is sent to when
the branch does not have its own `reply` object.
### Parallel Status
Parallel has three parts for the Status:
1. `conditions` which details the overall status of the Parallel object
1. `ingressChannelStatus` and `branchesStatuses` which convey the status of
underlying `Channel` and `Subscription` resource that are created as part of
this Parallel.
1. `address` which is exposed so that Parallel can be used where Addressable can
be used. Sending to this address will target the `Channel` which is fronting
this Parallel (same as `ingressChannelStatus`).
## Examples
Learn how to use Parallel by following the [examples](./samples/parallel/README.md)

View File

@ -1,4 +1,4 @@
The following examples will help you understand how to use Choice to describe
The following examples will help you understand how to use Parallel to describe
various flows.
## Prerequisites
@ -6,7 +6,7 @@ various flows.
All examples require:
- A Kubernetes cluster with
- Knative Eventing v0.8+
- Knative Eventing v0.9+
- Knative Service v0.8+
All examples are using the
@ -23,5 +23,5 @@ trivial filtering, transformation and routing of the incoming events.
The examples are:
- [Choice with multiple cases and global reply](./multiple-cases/README.md)
- [Choice with mutually exclusive cases](./mutual-exclusivity/README.md)
- [Parallel with multiple branches and global reply](./multiple-branches/README.md)
- [Parallel with mutually exclusive cases](./mutual-exclusivity/README.md)

View File

@ -1,6 +1,6 @@
---
title: "Choice Example"
linkTitle: "Choice"
title: "Parallel Example"
linkTitle: "Parallel"
weight: 10
type: "docs"
---

View File

@ -1,9 +1,9 @@
We are going to create a Choice with two cases:
We are going to create a Parallel with two branches:
- the first case accepts events with a time that is is even
- the second case accepts events with a time that is is odd
- the first branch accepts events with a time that is is even
- the second branch accepts events with a time that is is odd
The events produced by each case are then sent to the `event-display` service.
The events produced by each branch are then sent to the `event-display` service.
## Prerequisites
@ -12,7 +12,7 @@ Please refer to the sample overview for the [prerequisites](../README.md).
### Create the Knative Services
Let's first create the filter and transformer services that we will use in our
Choice.
Parallel.
```yaml
apiVersion: serving.knative.dev/v1alpha1
@ -78,20 +78,20 @@ spec:
kubectl create -f ./filters.yaml -f ./transformers.yaml
```
### Create the Choice
### Create the Parallel
The `choice.yaml` file contains the specifications for creating the Choice.
The `parallel.yaml` file contains the specifications for creating the Parallel.
```yaml
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
kind: Parallel
metadata:
name: odd-even-choice
name: odd-even-parallel
spec:
channelTemplate:
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
cases:
branches:
- filter:
ref:
apiVersion: serving.knative.dev/v1alpha1
@ -119,10 +119,10 @@ spec:
```
```shell
kubectl create -f ./choice.yaml
kubectl create -f ./parallel.yaml
```
### Create the CronJobSource targeting the Choice
### Create the CronJobSource targeting the Parallel
This will create a CronJobSource which will send a CloudEvent with {"message":
"Even or odd?"} as the data payload every minute.
@ -137,8 +137,8 @@ spec:
data: '{"message": "Even or odd?"}'
sink:
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
name: odd-even-choice
kind: Parallel
name: odd-even-parallel
```
```shell
@ -166,7 +166,7 @@ Context Attributes,
time: 2019-07-31T18:10:00.000309586Z
datacontenttype: application/json; charset=utf-8
Extensions,
knativehistory: odd-even-choice-kn-choice-0-kn-channel.default.svc.cluster.local, odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local
knativehistory: odd-even-parallel-kn-parallel-0-kn-channel.default.svc.cluster.local, odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local
Data,
{
"message": "we are even!"
@ -181,7 +181,7 @@ Context Attributes,
time: 2019-07-31T18:11:00.002649881Z
datacontenttype: application/json; charset=utf-8
Extensions,
knativehistory: odd-even-choice-kn-choice-1-kn-channel.default.svc.cluster.local, odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local
knativehistory: odd-even-parallel-kn-parallel-1-kn-channel.default.svc.cluster.local, odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local
Data,
{
"message": "this is odd!"

View File

@ -7,5 +7,5 @@ spec:
data: '{"message": "Even or odd?"}'
sink:
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
name: odd-even-choice
kind: Parallel
name: odd-even-parallel

View File

@ -1,12 +1,12 @@
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
kind: Parallel
metadata:
name: odd-even-choice
name: odd-even-parallel
spec:
channelTemplate:
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
cases:
branches:
- filter:
ref:
apiVersion: serving.knative.dev/v1alpha1

View File

@ -1,13 +1,13 @@
In this example, we are going to see how we can create a Choice with mutually
exclusive cases.
In this example, we are going to see how we can create a Parallel with mutually
exclusive branches.
This example is the same as the
[multiple cases example](../multiple-cases/README.md) except that we are now
[multiple barnaches example](../multiple-branches/README.md) except that we are now
going to rely on the Knative
[switcher](https://github.com/lionelvillard/knative-functions#switcher) function
[switch](https://github.com/lionelvillard/knative-functions#switch) function
to provide a soft mutual exclusivity guarantee.
NOTE: this example has to be deployed in the default namespace.
NOTE: this example must be deployed in the default namespace.
## Prerequisites
@ -16,7 +16,7 @@ Please refer to the sample overview for the [prerequisites](../README.md).
### Create the Knative Services
Let's first create the switcher and transformer services that we will use in our
Choice.
Parallel.
```yaml
apiVersion: serving.knative.dev/v1alpha1
@ -69,20 +69,20 @@ spec:
kubectl create -f ./switcher.yaml -f ./transformers.yaml
```
### Create the Choice
### Create the Parallel object
The `choice.yaml` file contains the specifications for creating the Choice.
The `parallel.yaml` file contains the specifications for creating the Parallel object.
```yaml
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
kind: Parallel
metadata:
name: me-odd-even-choice
name: me-odd-even-parallel
spec:
channelTemplate:
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
cases:
branches:
- filter:
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
subscriber:
@ -104,10 +104,10 @@ spec:
```
```shell
kubectl create -f ./choice.yaml
kubectl create -f ./parallel.yaml
```
### Create the CronJobSource targeting the Choice
### Create the CronJobSource targeting the Parallel object
This will create a CronJobSource which will send a CloudEvent with {"message":
"Even or odd?"} as the data payload every minute.
@ -122,8 +122,8 @@ spec:
data: '{"message": "Even or odd?"}'
sink:
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
name: me-odd-even-choice
kind: Parallel
name: me-odd-even-parallel
```
```shell
@ -151,7 +151,7 @@ Context Attributes,
time: 2019-07-31T20:56:00.000477587Z
datacontenttype: application/json; charset=utf-8
Extensions,
knativehistory: me-odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local, me-odd-even-choice-kn-choice-0-kn-channel.default.svc.cluster.local
knativehistory: me-odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local, me-odd-even-parallel-kn-parallel-0-kn-channel.default.svc.cluster.local
Data,
{
"message": "we are even!"
@ -166,7 +166,7 @@ Context Attributes,
time: 2019-07-31T20:57:00.000312243Z
datacontenttype: application/json; charset=utf-8
Extensions,
knativehistory: me-odd-even-choice-kn-choice-1-kn-channel.default.svc.cluster.local, me-odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local
knativehistory: me-odd-even-parallel-kn-parallel-1-kn-channel.default.svc.cluster.local, me-odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local
Data,
{
"message": "this is odd!"

View File

@ -7,5 +7,5 @@ spec:
data: '{"message": "Even or odd?"}'
sink:
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
name: me-odd-even-choice
kind: Parallel
name: me-odd-even-parallel

View File

@ -1,12 +1,12 @@
apiVersion: messaging.knative.dev/v1alpha1
kind: Choice
kind: Parallel
metadata:
name: me-odd-even-choice
name: me-odd-even-parallel
spec:
channelTemplate:
apiVersion: messaging.knative.dev/v1alpha1
kind: InMemoryChannel
cases:
branches:
- filter:
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
subscriber: