Configuration of a JetStream stream.
There are sensible defaults for most. If no subjects are given the name will be used as the only subject.
In order to add/update a stream, a configuration needs to be set. The typical usage would be to initialize all required objects on the stack and configure them, then pass the pointer to the configuration to js_AddStream or js_UpdateStream.
- Note
- The strings are applications owned and will not be freed by the library.
-
NATS server 2.10 added user-provided Metadata, storage Compression type, FirstSeq to specify the starting sequence number, and SubjectTransform.
- See also
- jsStreamConfig_Init
jsStreamConfig sc;
jsPlacement p;
jsStreamSource m;
jsExternalStream esm;
jsStreamSource s1;
jsStreamSource s2;
jsExternalStream esmS2;
const char *subjects[] = {"foo", "bar"};
const char *tags[] = {"tag1", "tag2"};
jsStreamSource *sources[] = {&s1, &s2};
jsRePublish rp;
jsStreamConfig_Init(&sc);
jsPlacement_Init(&p);
p.Cluster = "MyCluster";
p.Tags = tags;
p.TagsLen = 2;
jsStreamSource_Init(&m);
m.Name = "AStream";
m.OptStartSeq = 100;
m.FilterSubject = "foo";
jsExternalStream_Init(&esm);
esm.APIPrefix = "mirror.prefix.";
esm.DeliverPrefix = "deliver.prefix.";
m.External = &esm;
jsStreamSource_Init(&s1);
s1.Name = "StreamOne";
s1.OptStartSeq = 10;
s1.FilterSubject = "stream.one";
jsStreamSource_Init(&s2);
s2.Name = "StreamTwo";
s2.FilterSubject = "stream.two";
jsExternalStream_Init(&esmS2);
esmS2.APIPrefix = "mirror.prefix.";
esmS2.DeliverPrefix = "deliver.prefix.";
s2.External = &esmS2;
sc.Name = "MyStream";
sc.Subjects = subjects;
sc.SubjectsLen = 2;
sc.Retention = js_InterestPolicy;
sc.Replicas = 3;
sc.Placement = &p;
sc.Mirror = &m;
sc.Sources = sources;
sc.SourcesLen = 2;
// For RePublish subject:
jsRePublish_Init(&rp);
rp.Source = ">";
rp.Destination = "RP.>";
sc.RePublish = &rp;
s = js_AddStream(&si, js, &sc, NULL, &jerr);