All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nstream.adapter.mongodb.MongoDbEgressSettings Maven / Gradle / Ivy

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.mongodb;

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 MongoDB egress by {@link MongoDbPublishingAgent}.
 *
 * @see MongoDbPublishingAgent
 */
@Tag("mongoDbEgressSettings")
public class MongoDbEgressSettings implements AdapterSettings {

  private final String clientProvisionName;
  private final String database;
  private final String collection;

  public MongoDbEgressSettings(final String clientProvisionName,
                               final String database,
                               final String collection) {
    this.clientProvisionName = clientProvisionName;
    this.database = database;
    this.collection = collection;
  }

  public MongoDbEgressSettings() {
    this("mongoClientProvision", null, null);
  }

  /**
   * Name of mongo client provision to be used for publication.
   *
   * @return the client provision name
   */
  public String clientProvisionName() {
    return this.clientProvisionName;
  }

  /**
   * MongoDB database name to publish to.
   *
   * @return the database name
   */
  public String database() {
    return this.database;
  }

  /**
   * MongoDB collection name to publish to, within the given database.
   *
   * @return the collection name
   */
  public String collection() {
    return this.collection;
  }

  @Override
  public  Output debug(Output output) {
    output = output.write("MongoDbEgressSettings").write('.').write("of").write('(').write(')')
        .write('.').write("clientProvisionName").write('(').debug(this.clientProvisionName).write(')')
        .write('.').write("database").write('(').debug(this.database).write(')')
        .write('.').write("collection").write('(').debug(this.collection).write(')');

    return output;
  }

  @Override
  public String toString() {
    return Format.debug(this);
  }

  @Kind
  private static Form form;

  private static final MongoDbEgressSettings DEFAULT = new MongoDbEgressSettings();

  public static Form form() {
    if (MongoDbEgressSettings.form == null) {
      MongoDbEgressSettings.form = Form.forClass(MongoDbEgressSettings.class);
    }
    return MongoDbEgressSettings.form;
  }

  public static MongoDbEgressSettings defaultSettings() {
    return MongoDbEgressSettings.DEFAULT;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy