diff --git a/.gitignore b/.gitignore index 76a786dfd8..12d31a4ed2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .idea/ .vscode/ +.history/ \ No newline at end of file diff --git a/docs/eventing/choice.md b/docs/eventing/choice.md deleted file mode 100644 index a720969010..0000000000 --- a/docs/eventing/choice.md +++ /dev/null @@ -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) diff --git a/docs/eventing/parallel.md b/docs/eventing/parallel.md new file mode 100644 index 0000000000..509e32b711 --- /dev/null +++ b/docs/eventing/parallel.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) diff --git a/docs/eventing/samples/choice/README.md b/docs/eventing/samples/parallel/README.md similarity index 66% rename from docs/eventing/samples/choice/README.md rename to docs/eventing/samples/parallel/README.md index 67542771ea..5b295f5ca8 100644 --- a/docs/eventing/samples/choice/README.md +++ b/docs/eventing/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. ## 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) diff --git a/docs/eventing/samples/choice/_index.md b/docs/eventing/samples/parallel/_index.md similarity index 67% rename from docs/eventing/samples/choice/_index.md rename to docs/eventing/samples/parallel/_index.md index 96d9108ec5..1edcb6f3a3 100644 --- a/docs/eventing/samples/choice/_index.md +++ b/docs/eventing/samples/parallel/_index.md @@ -1,6 +1,6 @@ --- -title: "Choice Example" -linkTitle: "Choice" +title: "Parallel Example" +linkTitle: "Parallel" weight: 10 type: "docs" --- diff --git a/docs/eventing/samples/choice/multiple-cases/README.md b/docs/eventing/samples/parallel/multiple-branches/README.md similarity index 81% rename from docs/eventing/samples/choice/multiple-cases/README.md rename to docs/eventing/samples/parallel/multiple-branches/README.md index 08f885a088..5a3a71b7fc 100644 --- a/docs/eventing/samples/choice/multiple-cases/README.md +++ b/docs/eventing/samples/parallel/multiple-branches/README.md @@ -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!" diff --git a/docs/eventing/samples/choice/multiple-cases/_index.md b/docs/eventing/samples/parallel/multiple-branches/_index.md similarity index 100% rename from docs/eventing/samples/choice/multiple-cases/_index.md rename to docs/eventing/samples/parallel/multiple-branches/_index.md diff --git a/docs/eventing/samples/choice/multiple-cases/cron-source.yaml b/docs/eventing/samples/parallel/multiple-branches/cron-source.yaml similarity index 82% rename from docs/eventing/samples/choice/multiple-cases/cron-source.yaml rename to docs/eventing/samples/parallel/multiple-branches/cron-source.yaml index c328a32e1a..24c72e9ff7 100644 --- a/docs/eventing/samples/choice/multiple-cases/cron-source.yaml +++ b/docs/eventing/samples/parallel/multiple-branches/cron-source.yaml @@ -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 diff --git a/docs/eventing/samples/choice/multiple-cases/event-display.yaml b/docs/eventing/samples/parallel/multiple-branches/event-display.yaml similarity index 100% rename from docs/eventing/samples/choice/multiple-cases/event-display.yaml rename to docs/eventing/samples/parallel/multiple-branches/event-display.yaml diff --git a/docs/eventing/samples/choice/multiple-cases/filters.yaml b/docs/eventing/samples/parallel/multiple-branches/filters.yaml similarity index 100% rename from docs/eventing/samples/choice/multiple-cases/filters.yaml rename to docs/eventing/samples/parallel/multiple-branches/filters.yaml diff --git a/docs/eventing/samples/choice/multiple-cases/choice.yaml b/docs/eventing/samples/parallel/multiple-branches/parallel.yaml similarity index 90% rename from docs/eventing/samples/choice/multiple-cases/choice.yaml rename to docs/eventing/samples/parallel/multiple-branches/parallel.yaml index de9214a03d..1e0065d5db 100644 --- a/docs/eventing/samples/choice/multiple-cases/choice.yaml +++ b/docs/eventing/samples/parallel/multiple-branches/parallel.yaml @@ -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 diff --git a/docs/eventing/samples/choice/multiple-cases/transformers.yaml b/docs/eventing/samples/parallel/multiple-branches/transformers.yaml similarity index 100% rename from docs/eventing/samples/choice/multiple-cases/transformers.yaml rename to docs/eventing/samples/parallel/multiple-branches/transformers.yaml diff --git a/docs/eventing/samples/choice/mutual-exclusivity/README.md b/docs/eventing/samples/parallel/mutual-exclusivity/README.md similarity index 78% rename from docs/eventing/samples/choice/mutual-exclusivity/README.md rename to docs/eventing/samples/parallel/mutual-exclusivity/README.md index 79fff9fd3d..a871d04ac9 100644 --- a/docs/eventing/samples/choice/mutual-exclusivity/README.md +++ b/docs/eventing/samples/parallel/mutual-exclusivity/README.md @@ -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!" diff --git a/docs/eventing/samples/choice/mutual-exclusivity/_index.md b/docs/eventing/samples/parallel/mutual-exclusivity/_index.md similarity index 100% rename from docs/eventing/samples/choice/mutual-exclusivity/_index.md rename to docs/eventing/samples/parallel/mutual-exclusivity/_index.md diff --git a/docs/eventing/samples/choice/mutual-exclusivity/cron-source.yaml b/docs/eventing/samples/parallel/mutual-exclusivity/cron-source.yaml similarity index 82% rename from docs/eventing/samples/choice/mutual-exclusivity/cron-source.yaml rename to docs/eventing/samples/parallel/mutual-exclusivity/cron-source.yaml index 72478b1300..304892dec6 100644 --- a/docs/eventing/samples/choice/mutual-exclusivity/cron-source.yaml +++ b/docs/eventing/samples/parallel/mutual-exclusivity/cron-source.yaml @@ -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 diff --git a/docs/eventing/samples/choice/mutual-exclusivity/event-display.yaml b/docs/eventing/samples/parallel/mutual-exclusivity/event-display.yaml similarity index 100% rename from docs/eventing/samples/choice/mutual-exclusivity/event-display.yaml rename to docs/eventing/samples/parallel/mutual-exclusivity/event-display.yaml diff --git a/docs/eventing/samples/choice/mutual-exclusivity/choice.yaml b/docs/eventing/samples/parallel/mutual-exclusivity/parallel.yaml similarity index 88% rename from docs/eventing/samples/choice/mutual-exclusivity/choice.yaml rename to docs/eventing/samples/parallel/mutual-exclusivity/parallel.yaml index fdcc200cda..67c1addbb5 100644 --- a/docs/eventing/samples/choice/mutual-exclusivity/choice.yaml +++ b/docs/eventing/samples/parallel/mutual-exclusivity/parallel.yaml @@ -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: diff --git a/docs/eventing/samples/choice/mutual-exclusivity/switcher.yaml b/docs/eventing/samples/parallel/mutual-exclusivity/switcher.yaml similarity index 100% rename from docs/eventing/samples/choice/mutual-exclusivity/switcher.yaml rename to docs/eventing/samples/parallel/mutual-exclusivity/switcher.yaml diff --git a/docs/eventing/samples/choice/mutual-exclusivity/transformers.yaml b/docs/eventing/samples/parallel/mutual-exclusivity/transformers.yaml similarity index 100% rename from docs/eventing/samples/choice/mutual-exclusivity/transformers.yaml rename to docs/eventing/samples/parallel/mutual-exclusivity/transformers.yaml