Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subject mapping transforms for Streams #201

Open
6 of 15 tasks
Jarema opened this issue Feb 10, 2023 · 1 comment
Open
6 of 15 tasks

Subject mapping transforms for Streams #201

Jarema opened this issue Feb 10, 2023 · 1 comment
Labels
client Client related work enhancement New feature or request server:2.10.0

Comments

@Jarema
Copy link
Member

Jarema commented Feb 10, 2023

Overview

With nats-server 2.10.0 this feature will be released.

Server PR:
nats-io/nats-server#3814
nats-io/nats-server#3827

PR contains a lot of details.

Example Stream config with transforms:

{
  "name": "test2",
  "subjects": [
    "a",
    "b"
  ],
  "retention": "limits",
  "max_consumers": -1,
  "max_msgs_per_subject": -1,
  "max_msgs": -1,
  "max_bytes": -1,
  "max_age": 0,
  "max_msg_size": -1,
  "storage": "file",
  "discard": "old",
  "num_replicas": 1,
  "duplicate_window": 120000000000,
  "subject_transform": {
    "src": "fromtest.>",
    "dest": "input.>"
  },
"sources": [
    {
      "name": "test",
      "subject_transform_dest": "fromtest.>",
      "subject_filter" : ">"
    }
  ],
  "sealed": false,
  "deny_delete": false,
  "deny_purge": false,
  "allow_rollup_hdrs": false,
  "allow_direct": false,
  "mirror_direct": false
}

Besides exposing these new fields in the StreamConfig the client library should also automatically fill-in the subject transformation (subject filter and transform destination) fields in the StreamConfig for the bucket for the defined sources for the bucket, such that the source filter is "$KV.<sourced bucket name>.>" and the destination "$KV.<bucket name>.>".

Example of the StreamConfig for a bucket C that sources from KV buckets A and B:

{
  "name": "KV_C",
  "subjects": [
    "$KV.C.>"
  ],
  "retention": "limits",
  "max_consumers": -1,
  "max_msgs_per_subject": 1,
  "max_msgs": -1,
  "max_bytes": -1,
  "max_age": 0,
  "max_msg_size": -1,
  "storage": "file",
  "discard": "new",
  "num_replicas": 1,
  "duplicate_window": 120000000000,
  "placement": {
    "cluster": ""
  },
  "sources": [
    {
      "name": "KV_A",
      "filter_subject": "$KV.A.>",
      "subject_transform_dest": "$KV.C.>"
    },
    {
      "name": "KV_B",
      "filter_subject": "$KV.B.>",
      "subject_transform_dest": "$KV.C.>"
    }
  ],
  "sealed": false,
  "deny_delete": true,
  "deny_purge": false,
  "allow_rollup_hdrs": true,
  "allow_direct": true,
  "mirror_direct": false
}

(see nats-io/nats.go#1200 for reference)

Clients and Tools

Other Tasks

  • docs.nats.io updated @bruth
  • Update ADR to Implemented
  • Update client features spreadsheet

Client authors please update with your progress. If you open issues in your own repositories as a result of this request, please link them to this one by pasting the issue URL in a comment or main issue description.

@jnmoyne
Copy link
Contributor

jnmoyne commented Feb 10, 2023

At the moment the best way to play with it is (and check the schemas, and the generated stream and kv config JSON) is to build nats from the jnm/streamsourcetransform branch, or to look at nats.go where it's already implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related work enhancement New feature or request server:2.10.0
Projects
None yet
Development

No branches or pull requests