Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 469c1f4

Browse files
author
odacremolbap
committed
trigger docs primer
1 parent 749faea commit 469c1f4

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

docs/memory-broker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Memory Broker
22

3+
The `MemoryBroker` is a very simple and effective Broker that do not persist events. For stronger delivery guarantees see [RedisBroker](redis-broker.md).
4+
35
## Spec
46

57
```yaml

docs/redis-broker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Redis Broker
22

3+
The `RedisBroker` persist every ingested message at a Stream before returning an ACK to the event sender, making it more reliable than the [MemoryBroker](memory-broker.md).
4+
5+
It can be configured with any Redis instance version 6 and up, by providing connection parameters. If a Redis connection is not informed a Redis Deployment will be created by the TriggerMesh Core controller.
6+
37
## Spec
48

59
```yaml

docs/trigger.md

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,108 @@
11
# Trigger
22

3-
TODO
3+
Triggers objects build subscriptions from Brokers to event consumers. A Trigger contains 3 elements: broker reference, target and filter.
4+
5+
- The referenced broker will be reconfigured to address for the new subscription.
6+
- The target must be set to either a Kubernetes object that can be resolved to an URL, or a URL. In either case the target must expose an HTTP endpoint to receive events.
7+
- The filter declaratively selects which events should be forwarded to the target. In absence of filter all messages received at the Broker will be sent to the configured Target.
8+
9+
## Spec
10+
11+
```yaml
12+
apiVersion: eventing.triggermesh.io/v1alpha1
13+
kind: Trigger
14+
metadata:
15+
name: <trigger name>
16+
spec:
17+
broker:
18+
apiVersion: <Kubernetes apiVersion for the Broker object. Can inform 'group' instead>
19+
group: <Kubernetes group for the Broker object. Can inform 'apiVersion' instead>
20+
kind: <Kubernetes kind for the Broker object>
21+
name: <name of the Broker object>
22+
target: <Destination where events will be sent. Either reference to an objet or URI>
23+
ref:
24+
apiVersion: <Kubernetes apiVersion for the consumer object. Can inform 'group' instead>
25+
group: <Kubernetes group for the consumer object. Can inform 'apiVersion' instead>
26+
kind: <Kubernetes kind for the consumer object>
27+
name: <name of the consumer object>
28+
uri: <URI to the event consumer HTTP endpoint>
29+
delivery: <Event delivery options>
30+
retry: <Number of tries to deliver an event before considering failed>
31+
backoffDelay: <Backoff duration factor between retries>
32+
backoffPolicy: <Backoff policy applied to the delay, can be linear, exponential or constant>
33+
deadLetterSink: <Destination where underlivered events will be sent>
34+
ref:
35+
apiVersion: <Kubernetes apiVersion for the DLS object. Can inform 'group' instead>
36+
group: <Kubernetes group for the DLS object. Can inform 'apiVersion' instead>
37+
kind: <Kubernetes kind for the DLS object>
38+
name: <name of the DLS object>
39+
uri: <URI to the event DLS HTTP endpoint>
40+
filters: <Filter specification. See 'Filtering Events' section in this doc>
41+
```
42+
43+
- `spec.broker` must be a running broker that will be configured with this Trigger's configuration.
44+
- `spec.target` must refer to an endpoint that will receive events from the Broker. When the event consumer is a Kubernetes object it is prefered to use the `spec.target.ref` structure.
45+
- `spec.delivery` contains the logic to apply when an event cannot be delivered from the Broker to a Target, performing a number of retries, and finally sending to a dead letter sink if none of them succeed. Duration format for `spec.
46+
- `spec.filters` contain a set of filter expresions. See the [Filtering Events section](#filtering-events)
47+
48+
## Filtering Events
49+
50+
Events flowing through a Broker can be filtered before being sent to targets by using a range of expressions. TriggerMesh filter supports the [CloudEvents Subscriptions API filters](https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#324-filters), but will extend it with custom _dialects_ in the future.
51+
52+
There are 2 categories of filter dialects, those that perform actual filtering and those that group other dialects adding boolean logic to the inner dialects:
53+
54+
These filter dialects are meant to group inner dialects:
55+
56+
- `all` contains an array of dialects, all of them must resolve to true for positive matching.
57+
- `any` contains an array of dialects, at least one of them must resolve to true for positive matching.
58+
- `not` contains an array of dialects, all of them must resolve to false for positive matching.
59+
60+
These filter dialects contain matching logic applied to the [CloudEvent attributes](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#context-attributes):
61+
62+
- `exact` contains a key/value pair. For positive matching an attribute by that key/value must exist at the event.
63+
- `prefix` contains key/value pair. For positive matching an attribute by the exact key that contains a value that is prefixed by the one at the filter must exist at the event.
64+
- `suffix` contains a key/value pair. For positive matching an attribute by the exact key that contains a value that is suffixed by the one at the filter must exist at the event.
65+
66+
### Examples
67+
68+
Filter for events whose `type` attribute is set to `io.triggermesh.demo`
69+
70+
```yaml
71+
filters:
72+
- exact:
73+
type: my.demo.type
74+
```
75+
76+
Filter for events whose `type` attribute is set to `io.triggermesh.demo` and `category` is set to `test`
77+
78+
```yaml
79+
filters:
80+
- all:
81+
- exact:
82+
type: io.triggermesh.demo
83+
- exact:
84+
category: test
85+
```
86+
87+
Filter for events whose `type` attribute starts with `io.triggermesh.` or `type` is set to `io.tm.demo`
88+
89+
```yaml
90+
filters:
91+
- any:
92+
- prefix:
93+
type: io.triggermesh.
94+
- exact:
95+
type: io.tm.demo
96+
```
97+
98+
Filter for events whose `type` attribute does not ends with `.avoid.me` or `.avoid.me.too`.
99+
100+
```yaml
101+
filters:
102+
- not:
103+
- any:
104+
- suffix:
105+
type: .avoid.me
106+
- suffix:
107+
type: .avoid.me.too
108+
```

0 commit comments

Comments
 (0)