mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Add dagger map for injecting DnsWriter implementations
This is one of several CLs in a sequence for allowing per-TLD DNS implementations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129445641
This commit is contained in:
parent
770fd35e20
commit
a620d06239
24 changed files with 173 additions and 215 deletions
|
@ -1,56 +0,0 @@
|
|||
// Copyright 2016 The Domain Registry 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.model.dns;
|
||||
|
||||
/**
|
||||
* Transaction object for sending an atomic batch of updates for a single zone to the DNS server.
|
||||
*
|
||||
* <p>Here's an example of how you would publish updates for a domain and host:
|
||||
* <pre>
|
||||
* @Inject Provider<DnsWriter> dnsWriter;
|
||||
* try (DnsWriter writer = dnsWriter.get()) {
|
||||
* writer.publishDomain(domainName);
|
||||
* writer.publishHost(hostName);
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public interface DnsWriter extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Loads {@code domainName} from datastore and publishes its NS/DS records to the DNS server.
|
||||
* Replaces existing records for the exact name supplied with an NS record for each name server
|
||||
* and a DS record for each delegation signer stored in the registry for the supplied domain name.
|
||||
* If the domain is deleted or is in a "non-publish" state then any existing records are deleted.
|
||||
*
|
||||
* @param domainName the fully qualified domain name, with no trailing dot
|
||||
*/
|
||||
void publishDomain(String domainName);
|
||||
|
||||
/**
|
||||
* Loads {@code hostName} from datastore and publishes its A/AAAA glue records to the DNS server,
|
||||
* if it is used as an in-bailiwick nameserver. Orphaned glue records are prohibited. Replaces
|
||||
* existing records for the exact name supplied, with an A or AAAA record (as appropriate) for
|
||||
* each address stored in the registry, for the supplied host name. If the host is deleted then
|
||||
* the existing records are deleted. Assumes that this method will only be called for in-bailiwick
|
||||
* hosts. The registry does not have addresses for other hosts.
|
||||
*
|
||||
* @param hostName the fully qualified host name, with no trailing dot
|
||||
*/
|
||||
void publishHost(String hostName);
|
||||
|
||||
/** Commits the updates to the DNS server atomically. */
|
||||
@Override
|
||||
void close();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright 2016 The Domain Registry 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.model.dns;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/** Dagger qualifier for the fully-qualified zone name that's being updated. */
|
||||
@Qualifier
|
||||
@Documented
|
||||
public @interface DnsWriterZone {}
|
|
@ -255,6 +255,16 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
}
|
||||
|
||||
/** Backfill the Registry entities that were saved before this field was added. */
|
||||
// TODO(shikhman): Remove this backfill once it is populated on all Registry entities.
|
||||
@OnLoad
|
||||
void backfillDnsWriter() {
|
||||
if (dnsWriter == null) {
|
||||
dnsWriter = "VoidDnsWriter";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of the pricing engine that this TLD uses.
|
||||
*
|
||||
|
@ -266,6 +276,14 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
*/
|
||||
String pricingEngineClassName;
|
||||
|
||||
/**
|
||||
* The name of the DnsWriter that this TLD uses.
|
||||
*
|
||||
* <p>This must be a valid key for the map of DnsWriters injected by <code>
|
||||
* @Inject Map<String, DnsWriter></code>
|
||||
*/
|
||||
String dnsWriter;
|
||||
|
||||
/**
|
||||
* The unicode-aware representation of the TLD associated with this {@link Registry}.
|
||||
*
|
||||
|
@ -545,6 +563,10 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
return pricingEngineClassName;
|
||||
}
|
||||
|
||||
public String getDnsWriter() {
|
||||
return dnsWriter;
|
||||
}
|
||||
|
||||
public ImmutableSet<String> getAllowedRegistrantContactIds() {
|
||||
return nullToEmptyImmutableCopy(allowedRegistrantContactIds);
|
||||
}
|
||||
|
@ -616,6 +638,12 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setDnsWriter(String dnsWriter) {
|
||||
getInstance().dnsWriter = checkArgumentNotNull(dnsWriter);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Builder setAddGracePeriodLength(Duration addGracePeriodLength) {
|
||||
checkArgument(addGracePeriodLength.isLongerThan(Duration.ZERO),
|
||||
"addGracePeriodLength must be non-zero");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue