mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 20:17:51 +02:00
I'm setting it to three buckets across all tests, because the default one bucket wasn't realistic enough, and allowed some tests to pass that shouldn't have, essentially by accident. This also changes RegistryConfig from being an interface to being an abstract base class. The medium term goal here is to have it be a static class so that it can provide fields from the YAML-derived POJO in situations where Dagger injection isn't feasible. The expected end state is as follows: default-config.yaml -- The master config file that provides defaults for all values. nomulus-config.yaml -- A per-environment config file that overrides the defaults from the previous file. YamlConfig.java -- The POJO that the aforementioned YAML files are deserialized into. RegistryConfig.java -- Contains a static, memoized instance of YamlConfig and provides static methods for getting some of those values. ConfigModule -- Will become a static inner class of RegistryConfig, using Dagger to provide most of the fields from the memoized YamlConfig instance. This way, all configuration will be coming from a single place: RegistryConfig.java. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143567288
173 lines
5.8 KiB
Java
173 lines
5.8 KiB
Java
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
|
|
//
|
|
// 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
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// 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 google.registry.config;
|
|
|
|
import com.google.common.base.Ascii;
|
|
import com.google.common.base.Optional;
|
|
import com.google.common.net.HostAndPort;
|
|
import java.net.URL;
|
|
import org.joda.time.Duration;
|
|
|
|
/**
|
|
* Registry configuration for global constants that can't be injected.
|
|
*
|
|
* <p>The goal of this custom configuration system is to have our project environments configured
|
|
* in type-safe Java code that can be refactored, rather than XML files and system properties.
|
|
*/
|
|
public abstract class RegistryConfig {
|
|
|
|
/**
|
|
* Returns the App Engine project ID, which is based off the environment name.
|
|
*/
|
|
public static String getProjectId() {
|
|
String prodProjectId = "domain-registry";
|
|
RegistryEnvironment environment = RegistryEnvironment.get();
|
|
switch (environment) {
|
|
case PRODUCTION:
|
|
case UNITTEST:
|
|
case LOCAL:
|
|
return prodProjectId;
|
|
default:
|
|
return prodProjectId + "-" + Ascii.toLowerCase(environment.name());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the Google Cloud Storage bucket for storing backup snapshots.
|
|
*
|
|
* @see google.registry.export.ExportSnapshotServlet
|
|
*/
|
|
public abstract String getSnapshotsBucket();
|
|
|
|
/**
|
|
* Number of sharded commit log buckets.
|
|
*
|
|
* <p>This number is crucial for determining how much transactional throughput the system can
|
|
* allow, because it determines how many entity groups are available for writing commit logs.
|
|
* Since entity groups have a one transaction per second SLA (which is actually like ten in
|
|
* practice), a registry that wants to be able to handle one hundred transactions per second
|
|
* should have one hundred buckets.
|
|
*
|
|
* <p><b>Warning:</b> This can be raised but never lowered.
|
|
*
|
|
* @see google.registry.model.ofy.CommitLogBucket
|
|
*/
|
|
public static int getCommitLogBucketCount() {
|
|
switch (RegistryEnvironment.get()) {
|
|
case UNITTEST:
|
|
return 3;
|
|
default:
|
|
return 100;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the length of time before commit logs should be deleted from datastore.
|
|
*
|
|
* <p>The only reason you'll want to retain this commit logs in datastore is for performing
|
|
* point-in-time restoration queries for subsystems like RDE.
|
|
*
|
|
* @see google.registry.backup.DeleteOldCommitLogsAction
|
|
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
|
|
*/
|
|
public abstract Duration getCommitLogDatastoreRetention();
|
|
|
|
/**
|
|
* Returns {@code true} if TMCH certificate authority should be in testing mode.
|
|
*
|
|
* @see google.registry.tmch.TmchCertificateAuthority
|
|
*/
|
|
public abstract boolean getTmchCaTestingMode();
|
|
|
|
public abstract Optional<String> getECatcherAddress();
|
|
|
|
/**
|
|
* Returns the address of the Nomulus app HTTP server.
|
|
*
|
|
* <p>This is used by the {@code nomulus} tool to connect to the App Engine remote API.
|
|
*/
|
|
public abstract HostAndPort getServer();
|
|
|
|
/** Returns the amount of time a singleton should be cached, before expiring. */
|
|
public abstract Duration getSingletonCacheRefreshDuration();
|
|
|
|
/**
|
|
* Returns the amount of time a domain label list should be cached in memory before expiring.
|
|
*
|
|
* @see google.registry.model.registry.label.ReservedList
|
|
* @see google.registry.model.registry.label.PremiumList
|
|
*/
|
|
public abstract Duration getDomainLabelListCacheDuration();
|
|
|
|
/** Returns the amount of time a singleton should be cached in persist mode, before expiring. */
|
|
public abstract Duration getSingletonCachePersistDuration();
|
|
|
|
/**
|
|
* Returns the header text at the top of the reserved terms exported list.
|
|
*
|
|
* @see google.registry.export.ExportUtils#exportReservedTerms
|
|
*/
|
|
public abstract String getReservedTermsExportDisclaimer();
|
|
|
|
/**
|
|
* Returns a display name that is used on outgoing emails sent by Nomulus.
|
|
*
|
|
* @see google.registry.util.SendEmailUtils
|
|
*/
|
|
public abstract String getGoogleAppsAdminEmailDisplayName();
|
|
|
|
/**
|
|
* Returns the email address that outgoing emails from the app are sent from.
|
|
*
|
|
* @see google.registry.util.SendEmailUtils
|
|
*/
|
|
public abstract String getGoogleAppsSendFromEmailAddress();
|
|
|
|
/**
|
|
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
|
|
*
|
|
* @see "google.registry.whois.DomainWhoisResponse"
|
|
* @see "google.registry.whois.RegistrarWhoisResponse"
|
|
*/
|
|
public abstract String getRegistrarDefaultWhoisServer();
|
|
|
|
/**
|
|
* Returns the default referral URL that is used unless registrars have specified otherwise.
|
|
*/
|
|
public abstract URL getRegistrarDefaultReferralUrl();
|
|
|
|
/**
|
|
* Returns the number of EppResourceIndex buckets to be used.
|
|
*/
|
|
public abstract int getEppResourceIndexBucketCount();
|
|
|
|
/**
|
|
* Returns the base duration that gets doubled on each retry within {@code Ofy}.
|
|
*/
|
|
public abstract Duration getBaseOfyRetryDuration();
|
|
|
|
/**
|
|
* Returns the global automatic transfer length for contacts. After this amount of time has
|
|
* elapsed, the transfer is automatically approved.
|
|
*/
|
|
public abstract Duration getContactAutomaticTransferLength();
|
|
|
|
/**
|
|
* Returns the clientId of the registrar used by the {@code CheckApiServlet}.
|
|
*/
|
|
public abstract String getCheckApiServletRegistrarClientId();
|
|
|
|
// XXX: Please consider using ConfigModule instead of adding new methods to this file.
|
|
}
|