-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cloud Gateway - create additional registrations (#3181)
Signed-off-by: alexandr cumarav <[email protected]>
- Loading branch information
Showing
12 changed files
with
373 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...rc/main/java/org/zowe/apiml/cloudgatewayservice/config/AdditionalEurekaClientsHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.cloudgatewayservice.config; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.cloud.netflix.eureka.CloudEurekaClient; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Purpose of this holder is to keep additional {@link CloudEurekaClient} instances in the custom bean so that it does not interfere with standard `primary` eureka autoconfiguration. | ||
* <p> | ||
* Wrapper exposes proxy `shutdown` call of the client instances | ||
*/ | ||
@Getter | ||
@RequiredArgsConstructor | ||
public class AdditionalEurekaClientsHolder { | ||
private final List<CloudEurekaClient> discoveryClients; | ||
|
||
public void shutdown() { | ||
if (discoveryClients != null) { | ||
discoveryClients.forEach(CloudEurekaClient::shutdown); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...ateway-service/src/main/java/org/zowe/apiml/cloudgatewayservice/config/EurekaFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.cloudgatewayservice.config; | ||
|
||
import com.netflix.appinfo.ApplicationInfoManager; | ||
import com.netflix.appinfo.EurekaInstanceConfig; | ||
import com.netflix.appinfo.InstanceInfo; | ||
import org.springframework.cloud.netflix.eureka.CloudEurekaClient; | ||
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; | ||
import org.springframework.cloud.netflix.eureka.InstanceInfoFactory; | ||
import org.springframework.cloud.netflix.eureka.MutableDiscoveryClientOptionalArgs; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Eureka dependencies injection helper | ||
*/ | ||
@Component | ||
public class EurekaFactory { | ||
|
||
/** | ||
* Create new copy of instance info | ||
* | ||
* @param instanceConfig eureka instance config to copy from | ||
*/ | ||
InstanceInfo createInstanceInfo(EurekaInstanceConfig instanceConfig) { | ||
return new InstanceInfoFactory().create(instanceConfig); | ||
} | ||
|
||
public CloudEurekaClient createCloudEurekaClient(EurekaInstanceConfig eurekaInstanceConfig, InstanceInfo newInfo, EurekaClientConfigBean configBean, MutableDiscoveryClientOptionalArgs args, ApplicationContext context) { | ||
ApplicationInfoManager perClientAppManager = new ApplicationInfoManager(eurekaInstanceConfig, newInfo, null); | ||
return new CloudEurekaClient(perClientAppManager, configBean, args, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_____ _ _ _____ _ | ||
/ ____|| | | | / ____| | | | ||
| | | | ___ _ _ __| | | | __ __ _ | |_ ___ __ __ __ _ _ _ | ||
| | | | / _ \ | | | | / _` | | | |_ | / _` || __|/ _ \\ \ /\ / // _` || | | | | ||
| |____ | || (_) || |_| || (_| | | |__| || (_| || |_| __/ \ V V /| (_| || |_| | | ||
\_____||_| \___/ \__,_| \__,_| \_____| \__,_| \__|\___| \_/\_/ \__,_| \__, | | ||
__/ | | ||
|___/ |
Oops, something went wrong.