From c5ad6a4284968fb632cc6f904d5b156ba62feccd Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 7 Jun 2022 06:43:28 -0700 Subject: [PATCH] Align RePublish with server and add HeadersOnly, also add in AllowDirect for direct gets Signed-off-by: Derek Collison --- jsm.go | 11 +++++++---- test/js_test.go | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jsm.go b/jsm.go index 9170f8304..8b456193c 100644 --- a/jsm.go +++ b/jsm.go @@ -1,4 +1,4 @@ -// Copyright 2021 The NATS Authors +// Copyright 2021-2022 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -100,15 +100,18 @@ type StreamConfig struct { DenyDelete bool `json:"deny_delete,omitempty"` DenyPurge bool `json:"deny_purge,omitempty"` AllowRollup bool `json:"allow_rollup_hdrs,omitempty"` + AllowDirect bool `json:"allow_direct,omitempty"` // Allow republish of the message after being sequenced and stored. - RePublish *SubjectMapping `json:"republish,omitempty"` + RePublish *RePublish `json:"republish,omitempty"` } -// SubjectMapping allows a source subject to be mapped to a destination subject for republishing. -type SubjectMapping struct { +// RePublish is for republishing messages once committed to a stream. The original +// subject cis remapped from the subject pattern to the destination pattern. +type RePublish struct { Source string `json:"src,omitempty"` Destination string `json:"dest"` + HeadersOnly bool `json:"headers_only,omitempty"` } // Placement is used to guide placement of streams in clustered JetStream. diff --git a/test/js_test.go b/test/js_test.go index fcccf5e6c..0328e0630 100644 --- a/test/js_test.go +++ b/test/js_test.go @@ -6956,7 +6956,7 @@ func TestJetStreamRePublish(t *testing.T) { Name: "RP", Storage: nats.MemoryStorage, Subjects: []string{"foo", "bar", "baz"}, - RePublish: &nats.SubjectMapping{ + RePublish: &nats.RePublish{ Source: ">", Destination: "RP.>", },