Skip to content

Commit 6e8388e

Browse files
lionelvillardknative-prow-robot
authored andcommitted
Rename Choice to Parallel and cases to branches (#1786)
1 parent 533e6b7 commit 6e8388e

File tree

19 files changed

+95
-94
lines changed

19 files changed

+95
-94
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
.idea/
33
.vscode/
4+
.history/

docs/eventing/choice.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

docs/eventing/parallel.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: "Parallel"
3+
weight: 20
4+
type: "docs"
5+
---
6+
7+
Parallel CRD provides a way to easily define a list of branches, each receiving
8+
the same CloudEvent sent to the Parallel ingress channel. Typically, each branch
9+
consists of a filter function guarding the execution of the branch.
10+
11+
Parallel creates `Channel`s and `Subscription`s under the hood.
12+
13+
## Usage
14+
15+
### Parallel Spec
16+
17+
Parallel has three parts for the Spec:
18+
19+
1. `branches` defines the list of `filter` and `subscriber` pairs, one per branch,
20+
and optionally a `reply` object. For each branch:
21+
1. (optional) the `filter` is evaluated and when it returns an event the `subscriber` is
22+
executed. Both `filter` and `subscriber` must be `Callable`.
23+
1. the event returned by the `subscriber` is sent to the branch `reply`
24+
object. When the `reply` is empty, the event is sent to the `spec.reply`
25+
object (see below).
26+
1. (optional) `channelTemplate` defines the Template which will be used to
27+
create `Channel`s.
28+
1. (optional) `reply` defines where the result of each branch is sent to when
29+
the branch does not have its own `reply` object.
30+
31+
### Parallel Status
32+
33+
Parallel has three parts for the Status:
34+
35+
1. `conditions` which details the overall status of the Parallel object
36+
1. `ingressChannelStatus` and `branchesStatuses` which convey the status of
37+
underlying `Channel` and `Subscription` resource that are created as part of
38+
this Parallel.
39+
1. `address` which is exposed so that Parallel can be used where Addressable can
40+
be used. Sending to this address will target the `Channel` which is fronting
41+
this Parallel (same as `ingressChannelStatus`).
42+
43+
## Examples
44+
45+
Learn how to use Parallel by following the [examples](./samples/parallel/README.md)

docs/eventing/samples/choice/README.md renamed to docs/eventing/samples/parallel/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
The following examples will help you understand how to use Choice to describe
1+
The following examples will help you understand how to use Parallel to describe
22
various flows.
33

44
## Prerequisites
55

66
All examples require:
77

88
- A Kubernetes cluster with
9-
- Knative Eventing v0.8+
9+
- Knative Eventing v0.9+
1010
- Knative Service v0.8+
1111

1212
All examples are using the
@@ -23,5 +23,5 @@ trivial filtering, transformation and routing of the incoming events.
2323

2424
The examples are:
2525

26-
- [Choice with multiple cases and global reply](./multiple-cases/README.md)
27-
- [Choice with mutually exclusive cases](./mutual-exclusivity/README.md)
26+
- [Parallel with multiple branches and global reply](./multiple-branches/README.md)
27+
- [Parallel with mutually exclusive cases](./mutual-exclusivity/README.md)

docs/eventing/samples/choice/_index.md renamed to docs/eventing/samples/parallel/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Choice Example"
3-
linkTitle: "Choice"
2+
title: "Parallel Example"
3+
linkTitle: "Parallel"
44
weight: 10
55
type: "docs"
66
---

docs/eventing/samples/choice/multiple-cases/README.md renamed to docs/eventing/samples/parallel/multiple-branches/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
We are going to create a Choice with two cases:
1+
We are going to create a Parallel with two branches:
22

3-
- the first case accepts events with a time that is is even
4-
- the second case accepts events with a time that is is odd
3+
- the first branch accepts events with a time that is is even
4+
- the second branch accepts events with a time that is is odd
55

6-
The events produced by each case are then sent to the `event-display` service.
6+
The events produced by each branch are then sent to the `event-display` service.
77

88
## Prerequisites
99

@@ -12,7 +12,7 @@ Please refer to the sample overview for the [prerequisites](../README.md).
1212
### Create the Knative Services
1313

1414
Let's first create the filter and transformer services that we will use in our
15-
Choice.
15+
Parallel.
1616

1717
```yaml
1818
apiVersion: serving.knative.dev/v1alpha1
@@ -78,20 +78,20 @@ spec:
7878
kubectl create -f ./filters.yaml -f ./transformers.yaml
7979
```
8080

81-
### Create the Choice
81+
### Create the Parallel
8282

83-
The `choice.yaml` file contains the specifications for creating the Choice.
83+
The `parallel.yaml` file contains the specifications for creating the Parallel.
8484

8585
```yaml
8686
apiVersion: messaging.knative.dev/v1alpha1
87-
kind: Choice
87+
kind: Parallel
8888
metadata:
89-
name: odd-even-choice
89+
name: odd-even-parallel
9090
spec:
9191
channelTemplate:
9292
apiVersion: messaging.knative.dev/v1alpha1
9393
kind: InMemoryChannel
94-
cases:
94+
branches:
9595
- filter:
9696
ref:
9797
apiVersion: serving.knative.dev/v1alpha1
@@ -119,10 +119,10 @@ spec:
119119
```
120120
121121
```shell
122-
kubectl create -f ./choice.yaml
122+
kubectl create -f ./parallel.yaml
123123
```
124124

125-
### Create the CronJobSource targeting the Choice
125+
### Create the CronJobSource targeting the Parallel
126126

127127
This will create a CronJobSource which will send a CloudEvent with {"message":
128128
"Even or odd?"} as the data payload every minute.
@@ -137,8 +137,8 @@ spec:
137137
data: '{"message": "Even or odd?"}'
138138
sink:
139139
apiVersion: messaging.knative.dev/v1alpha1
140-
kind: Choice
141-
name: odd-even-choice
140+
kind: Parallel
141+
name: odd-even-parallel
142142
```
143143
144144
```shell
@@ -166,7 +166,7 @@ Context Attributes,
166166
time: 2019-07-31T18:10:00.000309586Z
167167
datacontenttype: application/json; charset=utf-8
168168
Extensions,
169-
knativehistory: odd-even-choice-kn-choice-0-kn-channel.default.svc.cluster.local, odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local
169+
knativehistory: odd-even-parallel-kn-parallel-0-kn-channel.default.svc.cluster.local, odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local
170170
Data,
171171
{
172172
"message": "we are even!"
@@ -181,7 +181,7 @@ Context Attributes,
181181
time: 2019-07-31T18:11:00.002649881Z
182182
datacontenttype: application/json; charset=utf-8
183183
Extensions,
184-
knativehistory: odd-even-choice-kn-choice-1-kn-channel.default.svc.cluster.local, odd-even-choice-kn-choice-kn-channel.default.svc.cluster.local
184+
knativehistory: odd-even-parallel-kn-parallel-1-kn-channel.default.svc.cluster.local, odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local
185185
Data,
186186
{
187187
"message": "this is odd!"
File renamed without changes.

docs/eventing/samples/choice/multiple-cases/cron-source.yaml renamed to docs/eventing/samples/parallel/multiple-branches/cron-source.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
data: '{"message": "Even or odd?"}'
88
sink:
99
apiVersion: messaging.knative.dev/v1alpha1
10-
kind: Choice
11-
name: odd-even-choice
10+
kind: Parallel
11+
name: odd-even-parallel

0 commit comments

Comments
 (0)