nstream.adapter.nats.NatsEgressSettings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nstream-adapter-nats Show documentation
Show all versions of nstream-adapter-nats Show documentation
Templates for consuming from and producing to NATS with Swim
The newest version!
// Copyright 2015-2024 Nstream, inc.
//
// Licensed under the Redis Source Available License 2.0 (RSALv2) Agreement;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://redis.com/legal/rsalv2-agreement/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package nstream.adapter.nats;
import nstream.adapter.common.AdapterSettings;
import swim.codec.Format;
import swim.codec.Output;
import swim.structure.Form;
import swim.structure.Kind;
import swim.structure.Tag;
/**
* Provides a concrete class to parse and store agent configuration
* used for NATS JetStream egress by {@link NatsPublishingAgent}.
*
* @see NatsPublishingAgent
*/
@Tag("natsEgressSettings")
public class NatsEgressSettings implements AdapterSettings {
private static final NatsEgressSettings DEFAULT = new NatsEgressSettings();
@Kind
private static Form form;
private final String connectionProvisionName;
private final String natsEgressStreamName;
private final String natsEgressSubjectName;
public NatsEgressSettings(final String connectionProvisionName, final String natsEgressStreamName,
String natsEgressSubjectName) {
this.connectionProvisionName = connectionProvisionName;
this.natsEgressStreamName = natsEgressStreamName;
this.natsEgressSubjectName = natsEgressSubjectName;
}
public NatsEgressSettings() {
this("foobar", "UndefinedStream",
"UndefinedSubject");
}
public static Form form() {
if (NatsEgressSettings.form == null) {
NatsEgressSettings.form = Form.forClass(NatsEgressSettings.class);
}
return NatsEgressSettings.form;
}
public static NatsEgressSettings defaultSettings() {
return NatsEgressSettings.DEFAULT;
}
public String getConnectionProvisionName() {
return this.connectionProvisionName;
}
/**
* Name of the Stream name to be used for publication.
*
* @return the Stream name string
*/
public String getNatsEgressStreamName() {
return this.natsEgressStreamName;
}
/**
* Name of the Subject name to be used for publication.
*
* @return the Subject name string
*/
public String getNatsEgressSubjectName() {
return this.natsEgressSubjectName;
}
@Override
public Output debug(Output output) {
output = output.write("NatsEgressSettings").write('.').write("of").write('(').write(')')
.write('.').write("connectionProvisionName").write('(').debug(this.connectionProvisionName).write(')')
.write('.').write("natsEgressStreamName").write('(').debug(this.natsEgressStreamName).write(')')
.write('.').write("natsEgressSubjectName").write('(').debug(this.natsEgressSubjectName).write(')');
return output;
}
@Override
public String toString() {
return Format.debug(this);
}
}