You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for UDF function transformations in PubSubToRedis template (#3338)
* Merge branch 'udb_redis'
* Update RedisHashIO to use AutoValue and move UDF comment in PubSubToRedis
* Specify standard charset as UTF-8
* Add assertions to RedisStreamsSink test
* Update deadletter Pub/Sub topic description
* Relax validation so DLQ is required when UDF is configured
* Apply formatting with spotless
---------
Co-authored-by: Ulada Butsenka <uladabutsenka@google.com>
Copy file name to clipboardExpand all lines: v2/pubsub-to-redis/README_Cloud_PubSub_to_Redis.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ Pub/Sub subscription and writes the message payload to Redis. The most common us
6
6
case of this template is to export logs to Redis Enterprise for advanced
7
7
search-based log analysis in real time.
8
8
9
+
Before writing to Redis, you can apply a JavaScript user-defined function to the
10
+
message payload. Any messages that experience processing failures are forwarded
11
+
to a Pub/Sub unprocessed topic for further troubleshooting and reprocessing.
12
+
9
13
For added security, enable an SSL connection when setting up your database
10
14
endpoint connection.
11
15
@@ -33,7 +37,21 @@ on [Metadata Annotations](https://github.com/GoogleCloudPlatform/DataflowTemplat
33
37
***redisSinkType**: The Redis sink. Supported values are `STRING_SINK, HASH_SINK, STREAMS_SINK, and LOGGING_SINK`. For example, `STRING_SINK`. Defaults to: STRING_SINK.
34
38
***connectionTimeout**: The Redis connection timeout in milliseconds. For example, `2000`. Defaults to: 2000.
35
39
***ttl**: The key expiration time in seconds. The `ttl` default for `HASH_SINK` is -1, which means it never expires.
40
+
***outputDeadletterTopic**: The Pub/Sub topic to forward unprocessable messages to. Messages that fail UDF transformation are forwarded here, Required if using a JavaScript UDF. For example, `projects/<PROJECT_ID>/topics/<TOPIC_NAME>`.
41
+
***javascriptTextTransformGcsPath**: The Cloud Storage URI of the .js file that defines the JavaScript user-defined function (UDF) to use. For example, `gs://my-bucket/my-udfs/my_file.js`.
42
+
***javascriptTextTransformFunctionName**: The name of the JavaScript user-defined function (UDF) to use. For example, if your JavaScript function code is `myTransform(inJson) { /*...do stuff...*/ }`, then the function name is `myTransform`. For sample JavaScript UDFs, see UDF Examples (https://github.com/GoogleCloudPlatform/DataflowTemplates#udf-examples).
43
+
***javascriptTextTransformReloadIntervalMinutes**: Specifies how frequently to reload the UDF, in minutes. If the value is greater than 0, Dataflow periodically checks the UDF file in Cloud Storage, and reloads the UDF if the file is modified. This parameter allows you to update the UDF while the pipeline is running, without needing to restart the job. If the value is `0`, UDF reloading is disabled. The default value is `0`.
44
+
45
+
46
+
## User-Defined functions (UDFs)
47
+
48
+
The Pub/Sub to Redis Template supports User-Defined functions (UDFs).
49
+
UDFs allow you to customize functionality by providing a JavaScript function
50
+
without having to maintain or build the entire template code.
36
51
52
+
Check [Create user-defined functions for Dataflow templates](https://cloud.google.com/dataflow/docs/guides/templates/create-template-udf)
53
+
and [Using UDFs](https://github.com/GoogleCloudPlatform/DataflowTemplates#using-udfs)
54
+
for more information about how to create and test those functions.
0 commit comments