Skip to content

Commit

Permalink
Change tabs in the Eventing tutorials (#18428)
Browse files Browse the repository at this point in the history
* change tabs in subs with multi filters

* change tabs in type cleanup

* fix formatting

* change tabs in max in fligt

* fix formatting

* change tabs in send legacy events
  • Loading branch information
grego952 authored Nov 21, 2023
1 parent 4707141 commit 34b32ac
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 282 deletions.
153 changes: 67 additions & 86 deletions docs/03-tutorials/00-eventing/evnt-02-subs-with-multiple-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,25 @@ The [Subscription](../../05-technical-reference/00-custom-resources/evnt-01-subs

To subscribe to multiple events, you need a [Subscription](../../05-technical-reference/00-custom-resources/evnt-01-subscription.md) custom resource. In the following example, you learn how to subscribe to events of two types: `order.received.v1` and `order.changed.v1`.

<div tabs name="Create a Subscription" group="create-subscription">
<details open>
<summary label="Kyma Dashboard">
Kyma Dashboard
</summary>
<!-- tabs:start -->

#### **Kyma Dashboard**

1. Go to **Namespaces** and select the default Namespace.
2. Go to **Configuration** > **Subscriptions** and click **Create Subscription+**.
3. Provide the following parameters:
- **Subscription name**: `lastorder-sub`
- **Types**: `order.received.v1` and `order.changed.v1`
- **Service**: `lastorder` (The sink field will be populated automatically.)
- **Type matching:**: `standard`
- **Type matching**: `standard`
- **Source**: `myapp`

> **NOTE:** You can add more types to your subscription if you want to subscribe to more event types.
4. Click **Create**.
5. Wait a few seconds for the Subscription to have status `READY`.

</details>
<details>
<summary label="kubectl">
kubectl
</summary>
#### **kubectl**

Run:
```bash
Expand All @@ -65,8 +59,7 @@ kubectl get subscriptions lastorder-sub -o=jsonpath="{.status.ready}"

The operation was successful if the returned status says `true`.

</details>
</div>
<!-- tabs:end -->

## Trigger the workload with an event

Expand All @@ -79,79 +72,67 @@ In the following example, you port-forward the [Event Publisher Proxy](../../05-
```
2. Publish an event of type `order.received.v1` to trigger your Function. In another terminal window, run:

<div tabs name="Publish an event" group="trigger-workload">
<details open>
<summary label="CloudEvents Conformance Tool">
CloudEvents Conformance Tool
</summary>

```bash
cloudevents send http://localhost:3000/publish \
--type order.received.v1 \
--id cc99dcdd-6f6d-43d6-afef-d024eb276584 \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderStatus\":\"received\"}" \
--yaml
```

</details>
<details>
<summary label="curl">
curl
</summary>

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.received.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: cc99dcdd-6f6d-43d6-afef-d024eb276584" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderStatus\":\"received\"}" \
http://localhost:3000/publish
```
</details>
</div>

3. Now, publish an event of type `order.changed.v1` to trigger your Function.

<div tabs name="Publish an event" group="trigger-workload2">
<details open>
<summary label="CloudEvents Conformance Tool">
CloudEvents Conformance Tool
</summary>

```bash
cloudevents send http://localhost:3000/publish \
--type order.changed.v1 \
--id 94064655-7e9e-4795-97a3-81bfd497aac6 \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderStatus\":\"changed\"}" \
--yaml
```

</details>
<details>
<summary label="curl">
curl
</summary>

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.changed.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: 94064655-7e9e-4795-97a3-81bfd497aac6" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderStatus\":\"changed\"}" \
http://localhost:3000/publish
```
</details>
</div>
<!-- tabs:start -->

#### **CloudEvents Conformance Tool**

```bash
cloudevents send http://localhost:3000/publish \
--type order.received.v1 \
--id cc99dcdd-6f6d-43d6-afef-d024eb276584 \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderStatus\":\"received\"}" \
--yaml
```

#### **curl**

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.received.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: cc99dcdd-6f6d-43d6-afef-d024eb276584" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderStatus\":\"received\"}" \
http://localhost:3000/publish
```

<!-- tabs:end -->

1. Now, publish an event of type `order.changed.v1` to trigger your Function.

<!-- tabs:start -->

#### **CloudEvents Conformance Tool**

```bash
cloudevents send http://localhost:3000/publish \
--type order.changed.v1 \
--id 94064655-7e9e-4795-97a3-81bfd497aac6 \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderStatus\":\"changed\"}" \
--yaml
```

#### **curl**

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.changed.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: 94064655-7e9e-4795-97a3-81bfd497aac6" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderStatus\":\"changed\"}" \
http://localhost:3000/publish
```

<!-- tabs:end -->

## Verify the event delivery

Expand Down
153 changes: 67 additions & 86 deletions docs/03-tutorials/00-eventing/evnt-03-type-cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ You learn how Eventing behaves when you create a [Subscription](../../05-technic
2. [Create a Function](../../02-get-started/04-trigger-workload-with-event.md#create-a-function).
3. For this tutorial, instead of the default code sample, replace the Function source with the following code:

<div tabs name="Deploy a Function" group="create-workload">
<details open>
<summary label="Kyma Dashboard">
Kyma Dashboard
</summary>
<!-- tabs:start -->

#### **Kyma Dashboard**

```js
module.exports = {
Expand All @@ -27,52 +25,45 @@ You learn how Eventing behaves when you create a [Subscription](../../05-technic
}
}
```
</details>
<details>
<summary label="kubectl">
kubectl
</summary>

```bash
cat <<EOF | kubectl apply -f -
apiVersion: serverless.kyma-project.io/v1alpha2
kind: Function
metadata:
name: lastorder
namespace: default
spec:
replicas: 1
resourceConfiguration:
function:
profile: S
build:
profile: local-dev
runtime: nodejs18
source:
inline:
source: |-
module.exports = {
main: async function (event, context) {
console.log("Received event: ", event.data, ", Event Type: ", event.extensions.request.headers['ce-type']);
return;
}
}
EOF
```

</details>
</div>
#### **kubectl**

```bash
cat <<EOF | kubectl apply -f -
apiVersion: serverless.kyma-project.io/v1alpha2
kind: Function
metadata:
name: lastorder
namespace: default
spec:
replicas: 1
resourceConfiguration:
function:
profile: S
build:
profile: local-dev
runtime: nodejs18
source:
inline:
source: |-
module.exports = {
main: async function (event, context) {
console.log("Received event: ", event.data, ", Event Type: ", event.extensions.request.headers['ce-type']);
return;
}
}
EOF
```

<!-- tabs:end -->

## Create a Subscription with Event type consisting of alphanumeric characters

Create a [Subscription](../../05-technical-reference/00-custom-resources/evnt-01-subscription.md) custom resource and subscribe for events of the type: `order.payment*success.v1`. Note that `order.payment*success.v1` contains a prohibited character, the asterisk `*`.

<div tabs name="Create a Subscription" group="create-subscription">
<details open>
<summary label="Kyma Dashboard">
Kyma Dashboard
</summary>
<!-- tabs:start -->

#### **Kyma Dashboard**

1. Go to **Namespaces** and select the default Namespace.
2. Go to **Configuration** > **Subscriptions** and click **Create Subscription+**.
Expand All @@ -86,11 +77,7 @@ Create a [Subscription](../../05-technical-reference/00-custom-resources/evnt-01
4. Click **Create**.
5. Wait a few seconds for the Subscription to have status `READY`.

</details>
<details>
<summary label="kubectl">
kubectl
</summary>
#### **kubectl**

Run:
```bash
Expand All @@ -114,8 +101,8 @@ kubectl get subscriptions lastorder-payment-sub -o=jsonpath="{.status.ready}"
```

The operation was successful if the returned status says `true`.
</details>
</div>

<!-- tabs:end -->

## Check the Subscription cleaned Event type

Expand All @@ -137,41 +124,35 @@ Next, you see that you can still publish events with the original Event name (i.
```
2. Publish an event to trigger your Function. In another terminal window, run:

<div tabs name="Publish an event" group="trigger-workload">
<details open>
<summary label="CloudEvents Conformance Tool">
CloudEvents Conformance Tool
</summary>
```bash
cloudevents send http://localhost:3000/publish \
--type "order.payment*success.v1" \
--id e4bcc616-c3a9-4840-9321-763aa23851fc \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderAmount\":\"1250\"}" \
--yaml
```
</details>
<details>
<summary label="curl">
curl
</summary>
<!-- tabs:start -->

#### **CloudEvents Conformance Tool**

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.payment*success.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: e4bcc616-c3a9-4840-9321-763aa23851fc" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderAmount\":\"1250\"}" \
http://localhost:3000/publish
```
</details>
</div>
```bash
cloudevents send http://localhost:3000/publish \
--type "order.payment*success.v1" \
--id e4bcc616-c3a9-4840-9321-763aa23851fc \
--source myapp \
--datacontenttype application/json \
--data "{\"orderCode\":\"3211213\", \"orderAmount\":\"1250\"}" \
--yaml
```

#### **curl**

```bash
curl -v -X POST \
-H "ce-specversion: 1.0" \
-H "ce-type: order.payment*success.v1" \
-H "ce-source: myapp" \
-H "ce-eventtypeversion: v1" \
-H "ce-id: e4bcc616-c3a9-4840-9321-763aa23851fc" \
-H "content-type: application/json" \
-d "{\"orderCode\":\"3211213\", \"orderAmount\":\"1250\"}" \
http://localhost:3000/publish
```

<!-- tabs:end -->

## Verify the event delivery

Expand Down
Loading

0 comments on commit 34b32ac

Please sign in to comment.