mirror of https://github.com/knative/docs.git
Rename Choice to Parallel and cases to branches (#1786)
This commit is contained in:
parent
533e6b7bf3
commit
6e8388eb2a
|
@ -1,3 +1,4 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.history/
|
|
@ -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)
|
|
|
@ -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)
|
|
@ -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.
|
various flows.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
@ -6,7 +6,7 @@ various flows.
|
||||||
All examples require:
|
All examples require:
|
||||||
|
|
||||||
- A Kubernetes cluster with
|
- A Kubernetes cluster with
|
||||||
- Knative Eventing v0.8+
|
- Knative Eventing v0.9+
|
||||||
- Knative Service v0.8+
|
- Knative Service v0.8+
|
||||||
|
|
||||||
All examples are using the
|
All examples are using the
|
||||||
|
@ -23,5 +23,5 @@ trivial filtering, transformation and routing of the incoming events.
|
||||||
|
|
||||||
The examples are:
|
The examples are:
|
||||||
|
|
||||||
- [Choice with multiple cases and global reply](./multiple-cases/README.md)
|
- [Parallel with multiple branches and global reply](./multiple-branches/README.md)
|
||||||
- [Choice with mutually exclusive cases](./mutual-exclusivity/README.md)
|
- [Parallel with mutually exclusive cases](./mutual-exclusivity/README.md)
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Choice Example"
|
title: "Parallel Example"
|
||||||
linkTitle: "Choice"
|
linkTitle: "Parallel"
|
||||||
weight: 10
|
weight: 10
|
||||||
type: "docs"
|
type: "docs"
|
||||||
---
|
---
|
|
@ -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 first branch accepts events with a time that is is even
|
||||||
- the second case accepts events with a time that is is odd
|
- 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
|
## Prerequisites
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Please refer to the sample overview for the [prerequisites](../README.md).
|
||||||
### Create the Knative Services
|
### Create the Knative Services
|
||||||
|
|
||||||
Let's first create the filter and transformer services that we will use in our
|
Let's first create the filter and transformer services that we will use in our
|
||||||
Choice.
|
Parallel.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
||||||
|
@ -78,20 +78,20 @@ spec:
|
||||||
kubectl create -f ./filters.yaml -f ./transformers.yaml
|
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
|
```yaml
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
metadata:
|
metadata:
|
||||||
name: odd-even-choice
|
name: odd-even-parallel
|
||||||
spec:
|
spec:
|
||||||
channelTemplate:
|
channelTemplate:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: InMemoryChannel
|
kind: InMemoryChannel
|
||||||
cases:
|
branches:
|
||||||
- filter:
|
- filter:
|
||||||
ref:
|
ref:
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
||||||
|
@ -119,10 +119,10 @@ spec:
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```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":
|
This will create a CronJobSource which will send a CloudEvent with {"message":
|
||||||
"Even or odd?"} as the data payload every minute.
|
"Even or odd?"} as the data payload every minute.
|
||||||
|
@ -137,8 +137,8 @@ spec:
|
||||||
data: '{"message": "Even or odd?"}'
|
data: '{"message": "Even or odd?"}'
|
||||||
sink:
|
sink:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
name: odd-even-choice
|
name: odd-even-parallel
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -166,7 +166,7 @@ Context Attributes,
|
||||||
time: 2019-07-31T18:10:00.000309586Z
|
time: 2019-07-31T18:10:00.000309586Z
|
||||||
datacontenttype: application/json; charset=utf-8
|
datacontenttype: application/json; charset=utf-8
|
||||||
Extensions,
|
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,
|
Data,
|
||||||
{
|
{
|
||||||
"message": "we are even!"
|
"message": "we are even!"
|
||||||
|
@ -181,7 +181,7 @@ Context Attributes,
|
||||||
time: 2019-07-31T18:11:00.002649881Z
|
time: 2019-07-31T18:11:00.002649881Z
|
||||||
datacontenttype: application/json; charset=utf-8
|
datacontenttype: application/json; charset=utf-8
|
||||||
Extensions,
|
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,
|
Data,
|
||||||
{
|
{
|
||||||
"message": "this is odd!"
|
"message": "this is odd!"
|
|
@ -7,5 +7,5 @@ spec:
|
||||||
data: '{"message": "Even or odd?"}'
|
data: '{"message": "Even or odd?"}'
|
||||||
sink:
|
sink:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
name: odd-even-choice
|
name: odd-even-parallel
|
|
@ -1,12 +1,12 @@
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
metadata:
|
metadata:
|
||||||
name: odd-even-choice
|
name: odd-even-parallel
|
||||||
spec:
|
spec:
|
||||||
channelTemplate:
|
channelTemplate:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: InMemoryChannel
|
kind: InMemoryChannel
|
||||||
cases:
|
branches:
|
||||||
- filter:
|
- filter:
|
||||||
ref:
|
ref:
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
|
@ -1,13 +1,13 @@
|
||||||
In this example, we are going to see how we can create a Choice with mutually
|
In this example, we are going to see how we can create a Parallel with mutually
|
||||||
exclusive cases.
|
exclusive branches.
|
||||||
|
|
||||||
This example is the same as the
|
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
|
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.
|
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
|
## Prerequisites
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ Please refer to the sample overview for the [prerequisites](../README.md).
|
||||||
### Create the Knative Services
|
### Create the Knative Services
|
||||||
|
|
||||||
Let's first create the switcher and transformer services that we will use in our
|
Let's first create the switcher and transformer services that we will use in our
|
||||||
Choice.
|
Parallel.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
||||||
|
@ -69,20 +69,20 @@ spec:
|
||||||
kubectl create -f ./switcher.yaml -f ./transformers.yaml
|
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
|
```yaml
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
metadata:
|
metadata:
|
||||||
name: me-odd-even-choice
|
name: me-odd-even-parallel
|
||||||
spec:
|
spec:
|
||||||
channelTemplate:
|
channelTemplate:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: InMemoryChannel
|
kind: InMemoryChannel
|
||||||
cases:
|
branches:
|
||||||
- filter:
|
- filter:
|
||||||
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
|
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
|
||||||
subscriber:
|
subscriber:
|
||||||
|
@ -104,10 +104,10 @@ spec:
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```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":
|
This will create a CronJobSource which will send a CloudEvent with {"message":
|
||||||
"Even or odd?"} as the data payload every minute.
|
"Even or odd?"} as the data payload every minute.
|
||||||
|
@ -122,8 +122,8 @@ spec:
|
||||||
data: '{"message": "Even or odd?"}'
|
data: '{"message": "Even or odd?"}'
|
||||||
sink:
|
sink:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
name: me-odd-even-choice
|
name: me-odd-even-parallel
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -151,7 +151,7 @@ Context Attributes,
|
||||||
time: 2019-07-31T20:56:00.000477587Z
|
time: 2019-07-31T20:56:00.000477587Z
|
||||||
datacontenttype: application/json; charset=utf-8
|
datacontenttype: application/json; charset=utf-8
|
||||||
Extensions,
|
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,
|
Data,
|
||||||
{
|
{
|
||||||
"message": "we are even!"
|
"message": "we are even!"
|
||||||
|
@ -166,7 +166,7 @@ Context Attributes,
|
||||||
time: 2019-07-31T20:57:00.000312243Z
|
time: 2019-07-31T20:57:00.000312243Z
|
||||||
datacontenttype: application/json; charset=utf-8
|
datacontenttype: application/json; charset=utf-8
|
||||||
Extensions,
|
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,
|
Data,
|
||||||
{
|
{
|
||||||
"message": "this is odd!"
|
"message": "this is odd!"
|
|
@ -7,5 +7,5 @@ spec:
|
||||||
data: '{"message": "Even or odd?"}'
|
data: '{"message": "Even or odd?"}'
|
||||||
sink:
|
sink:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
name: me-odd-even-choice
|
name: me-odd-even-parallel
|
|
@ -1,12 +1,12 @@
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: Choice
|
kind: Parallel
|
||||||
metadata:
|
metadata:
|
||||||
name: me-odd-even-choice
|
name: me-odd-even-parallel
|
||||||
spec:
|
spec:
|
||||||
channelTemplate:
|
channelTemplate:
|
||||||
apiVersion: messaging.knative.dev/v1alpha1
|
apiVersion: messaging.knative.dev/v1alpha1
|
||||||
kind: InMemoryChannel
|
kind: InMemoryChannel
|
||||||
cases:
|
branches:
|
||||||
- filter:
|
- filter:
|
||||||
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
|
uri: "http://me-even-odd-switcher.default.svc.cluster.local/0"
|
||||||
subscriber:
|
subscriber:
|
Loading…
Reference in New Issue