Skip to content

Commit

Permalink
add a listener spec and wire for channelDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
argha-c committed Oct 3, 2024
1 parent 8a08471 commit 894b825
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.slf4j.LoggerFactory;

public abstract class BaseServerStartup {

protected static final Logger LOG = LoggerFactory.getLogger(BaseServerStartup.class);

protected final ServerStatusManager serverStatusManager;
Expand Down Expand Up @@ -124,6 +125,7 @@ public void init() throws Exception {
}

// TODO(carl-mastrangelo): remove this after 2.1.7

/**
* Use {@link #chooseAddrsAndChannels(ChannelGroup)} instead.
*/
Expand All @@ -146,6 +148,12 @@ protected ChannelConfig defaultChannelDependencies(String listenAddressName) {
return channelDependencies;
}

protected ChannelConfig defaultChannelDependencies(ListenerSpec listenSpec) {
ChannelConfig channelDependencies = new ChannelConfig();
addChannelDependencies(channelDependencies, listenSpec.addressName());
return channelDependencies;
}

protected void addChannelDependencies(
ChannelConfig channelDeps,
@SuppressWarnings("unused") String listenAddressName) { // listenAddressName is used by subclasses
Expand Down Expand Up @@ -193,7 +201,7 @@ public static boolean chooseBooleanChannelProperty(
String listenAddressPropertyName = "server." + listenAddressName + "." + propertySuffix;

Boolean value = new ChainedDynamicProperty.DynamicBooleanPropertyThatSupportsNull(
listenAddressPropertyName, null)
listenAddressPropertyName, null)
.get();
if (value == null) {
value = new DynamicBooleanProperty(globalPropertyName, defaultValue)
Expand Down Expand Up @@ -293,6 +301,7 @@ public static void addHttp2DefaultConfig(ChannelConfig config, String listenAddr
}

// TODO(carl-mastrangelo): remove this after 2.1.7

/**
* Use {@link #logAddrConfigured(SocketAddress)} instead.
*/
Expand All @@ -302,6 +311,7 @@ protected void logPortConfigured(int port) {
}

// TODO(carl-mastrangelo): remove this after 2.1.7

/**
* Use {@link #logAddrConfigured(SocketAddress, ServerSslConfig)} instead.
*/
Expand All @@ -311,6 +321,7 @@ protected void logPortConfigured(int port, ServerSslConfig serverSslConfig) {
}

// TODO(carl-mastrangelo): remove this after 2.1.7

/**
* Use {@link #logAddrConfigured(SocketAddress, AsyncMapping)} instead.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2024 Netflix, Inc.
*
* 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 com.netflix.zuul.netty.server;

/**
* @author Argha C
* @since 10/2/24
*/

import java.net.SocketAddress;
import java.util.Objects;

/**
* A specification of an address to listen on.
*/

public record ListenerSpec(String addressName, boolean defaultAddressEnabled, SocketAddress defaultAddressValue) {

public ListenerSpec {
Objects.requireNonNull(addressName, "addressName");
Objects.requireNonNull(defaultAddressEnabled, "defaultAddressEnabled");
Objects.requireNonNull(defaultAddressValue, "defaultAddressValue");
}

/**
* The fast property name that indicates if this address is enabled. This is used when overriding
* {@link #defaultAddressEnabled}.
*/
public String addressEnabledPropertyName() {
return "zuul.server." + addressName + ".enabled";
}

/**
* The fast property to override the default port for the address name
*/
@Deprecated
public String portPropertyName() {
return "zuul.server.port." + addressName;
}

/**
* The fast property to override the default address name
*/
public String addressPropertyName() {
return "zuul.server.addr." + addressName;
}
}

0 comments on commit 894b825

Please sign in to comment.