mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +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,18 +0,0 @@
|
|||
package(
|
||||
default_visibility = ["//java/google/registry:registry_project"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
|
||||
java_library(
|
||||
name = "writer",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/base",
|
||||
"//third_party/java/dagger",
|
||||
"//third_party/java/jsr305_annotations",
|
||||
"//third_party/java/jsr330_inject",
|
||||
"//java/google/registry/model",
|
||||
],
|
||||
)
|
|
@ -1,49 +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.dns.writer;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import google.registry.model.dns.DnsWriter;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* {@link DnsWriter} that doesn't actually update records in a DNS server.
|
||||
*
|
||||
* <p>All this class does is write its displeasure to the logs.
|
||||
*/
|
||||
public final class VoidDnsWriter implements DnsWriter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(VoidDnsWriter.class.getName());
|
||||
|
||||
private final Set<String> names = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void publishDomain(String domainName) {
|
||||
names.add(domainName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishHost(String hostName) {
|
||||
names.add(hostName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
logger.warning("Ignoring DNS zone updates! No DnsWriterFactory implementation specified!\n"
|
||||
+ Joiner.on('\n').join(names));
|
||||
}
|
||||
}
|
|
@ -1,29 +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.dns.writer;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.model.dns.DnsWriter;
|
||||
|
||||
/** Dagger module that disables DNS updates. */
|
||||
@Module
|
||||
public final class VoidDnsWriterModule {
|
||||
|
||||
@Provides
|
||||
static DnsWriter provideDnsWriter() {
|
||||
return new VoidDnsWriter();
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ java_library(
|
|||
"//third_party/java/dagger",
|
||||
"//third_party/java/joda_time",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns/writer",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/util",
|
||||
],
|
||||
|
|
|
@ -22,7 +22,10 @@ import com.google.api.services.dns.DnsScopes;
|
|||
import com.google.common.base.Function;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import dagger.multibindings.StringKey;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import java.util.Set;
|
||||
|
||||
/** Dagger module for Google Cloud DNS service connection objects. */
|
||||
|
@ -39,4 +42,11 @@ public final class CloudDnsModule {
|
|||
.setApplicationName(projectId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoMap
|
||||
@StringKey(CloudDnsWriter.NAME)
|
||||
static DnsWriter provideCloudDnsWriter(CloudDnsWriter writer) {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ import com.google.common.collect.ImmutableSet.Builder;
|
|||
import com.google.common.net.InternetDomainName;
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.model.dns.DnsWriter;
|
||||
import google.registry.model.dns.DnsWriterZone;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import google.registry.dns.writer.DnsWriterZone;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -59,6 +59,12 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
class CloudDnsWriter implements DnsWriter {
|
||||
|
||||
/**
|
||||
* The name of the pricing engine, as used in {@code Registry.dnsWriter}. Remember to change
|
||||
* the value on affected Registry objects to prevent runtime failures.
|
||||
*/
|
||||
public static final String NAME = "CloudDnsWriter";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
// This is the default max QPS for Cloud DNS. It can be increased by contacting the team
|
||||
|
|
|
@ -21,6 +21,7 @@ java_library(
|
|||
"//third_party/java/jsr305_annotations",
|
||||
"//third_party/java/jsr330_inject",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns/writer",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/util",
|
||||
],
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.model.dns.DnsWriter;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -75,6 +75,12 @@ import org.xbill.DNS.Update;
|
|||
*/
|
||||
public class DnsUpdateWriter implements DnsWriter {
|
||||
|
||||
/**
|
||||
* The name of the pricing engine, as used in {@code Registry.dnsWriter}. Remember to change
|
||||
* the value on affected Registry objects to prevent runtime failures.
|
||||
*/
|
||||
public static final String NAME = "DnsUpdateWriter";
|
||||
|
||||
private final Duration dnsTimeToLive;
|
||||
private final DnsMessageTransport transport;
|
||||
private final Clock clock;
|
||||
|
|
|
@ -14,21 +14,26 @@
|
|||
|
||||
package google.registry.dns.writer.dnsupdate;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.model.dns.DnsWriter;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import dagger.multibindings.StringKey;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
/** Dagger module that provides a DnsUpdateWriter. */
|
||||
@Module
|
||||
public abstract class DnsUpdateWriterModule {
|
||||
|
||||
@Binds
|
||||
abstract DnsWriter provideDnsWriter(DnsUpdateWriter dnsWriter);
|
||||
|
||||
@Provides
|
||||
static SocketFactory provideSocketFactory() {
|
||||
return SocketFactory.getDefault();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoMap
|
||||
@StringKey(DnsUpdateWriter.NAME)
|
||||
static DnsWriter provideDnsUpdateWriter(DnsUpdateWriter writer) {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue