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

Commit b997d49

Browse files
author
Pablo Mercado
authored
Merge pull request #117 from triggermesh/task/make-redis-id-tracking-opt-in
Redis: redis id tracking as opt in
2 parents 9f465c3 + 780e4f3 commit b997d49

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

config/300-redisbroker.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ spec:
141141
description: Maximum number of items (approximate) the Redis stream can host.
142142
type: integer
143143
default: 1000
144-
144+
enableTrackingID:
145+
description: Whether the Redis ID for the event is added as a CloudEvents attribute. Defaults to false
146+
type: boolean
145147
broker:
146148
description: Broker options.
147149
type: object

docs/redis-broker.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ spec:
4141
tlsSkipVerify: <boolean that skips verifying TLS certificates. Optional, defaults to false>
4242
stream: <Redis stream name. Optional, defaults to a combination of namespace and broker name>
4343
streamMaxLen: <maximum number of items the Redis stream can host. Optional, defaults to unlimited>
44+
enableTrackingID: <boolean that indicates if the Redis ID should be written as the CloudEvent attribute triggermeshbackendid>
4445
broker:
4546
port: <HTTP port for ingesting events>
4647
observability:
4748
valueFromConfigMap: <kubernetes ConfigMap that contains observability configuration>
4849
```
4950
50-
The only `RedisBroker` specific parameters are:
51+
The `RedisBroker` specific parameters are:
5152

5253
- `spec.redis.connection`. When not used the broker will spin up a managed Redis Deployment. However for production scenarios that require HA and hardened security it is recommended to provide the connection to a user managed Redis instance.
5354
- `spec.stream` is the Redis stream name to be used by the broker. If it doesn't exists the Broker will create it.
5455
- `spec.streamMaxLen` is the maximum number of elements that the stream will contain.
56+
- `spec.enableTrackingID` when set adds the `triggermeshbackendid` CloudEvents attribute containing the Redis ID for the message to all outgoing events.
5557

5658
The `spec.broker` section contains generic Borker parameters:
5759

pkg/apis/eventing/v1alpha1/redisbroker_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ type Redis struct {
8080

8181
// Maximum number of items the stream can host.
8282
StreamMaxLen *int `json:"streamMaxLen,omitempty"`
83+
84+
// Whether the Redis ID for the event is added as a CloudEvents attribute.
85+
EnableTrackingID *bool `json:"enableTrackingID,omitempty"`
8386
}
8487

8588
// SecretValueFromSource represents the source of a secret value

pkg/reconciler/redisbroker/reconciler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ func redisDeploymentOption(rb *eventingv1alpha1.RedisBroker, redisSvc *corev1.Se
6060
}
6161
resources.ContainerAddEnvFromValue("REDIS_STREAM_MAX_LEN", maxLen)(c)
6262

63+
if rb.Spec.Redis != nil && rb.Spec.Redis.EnableTrackingID != nil && *rb.Spec.Redis.EnableTrackingID {
64+
resources.ContainerAddEnvFromValue("REDIS_TRACKING_ID_ENABLED", "true")(c)
65+
}
66+
6367
if rb.IsUserProvidedRedis() {
6468

6569
// Standalone connections require an address, while cluster connections require an

0 commit comments

Comments
 (0)