Skip to content

Commit

Permalink
feat(discovery): refactor to use common discovery abstraction from ko…
Browse files Browse the repository at this point in the history
…rk-core (#975)
  • Loading branch information
cfieber authored Jul 10, 2020
1 parent 4297d02 commit 885722e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 201 deletions.
1 change: 0 additions & 1 deletion echo-core/echo-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies {

implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.apache.commons:commons-lang3"
implementation "com.netflix.eureka:eureka-client"

implementation "com.hubspot.jinjava:jinjava"
implementation "io.reactivex:rxjava"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

import com.netflix.spinnaker.config.PluginsAutoConfiguration;
import com.netflix.spinnaker.echo.api.events.EventListener;
import com.netflix.spinnaker.echo.discovery.DiscoveryPollingConfiguration;
import com.netflix.spinnaker.echo.events.EventPropagator;
import com.netflix.spinnaker.kork.PlatformComponents;
import com.netflix.spinnaker.kork.artifacts.parsing.DefaultJinjavaFactory;
import com.netflix.spinnaker.kork.artifacts.parsing.JinjaArtifactExtractor;
import com.netflix.spinnaker.kork.artifacts.parsing.JinjavaFactory;
Expand All @@ -39,11 +37,7 @@
"com.netflix.spinnaker.echo.build",
"com.netflix.spinnaker.echo.events",
})
@Import({
PlatformComponents.class,
DiscoveryPollingConfiguration.class,
PluginsAutoConfiguration.class
})
@Import({PluginsAutoConfiguration.class})
public class EchoCoreConfig {
private ApplicationContext context;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions echo-notifications/echo-notifications.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ dependencies {
implementation "com.netflix.spinnaker.kork:kork-artifacts"
implementation "com.netflix.spinnaker.kork:kork-web"
implementation "commons-codec:commons-codec"
implementation "javax.mail:javax.mail-api:1.6.2"
implementation "org.springframework.boot:spring-boot-starter-mail"
implementation "org.springframework.boot:spring-boot-starter-freemarker"
implementation "org.jsoup:jsoup:1.8.3"
implementation "com.atlassian.commonmark:commonmark:0.9.0"
testImplementation "com.icegreen:greenmail:1.4.0"
testImplementation("com.icegreen:greenmail:1.5.14") {
exclude group: "com.sun.mail", module: "javax.mail"
}
testImplementation "org.apache.httpcomponents:httpclient"
testImplementation "org.spockframework:spock-spring"
testImplementation "org.springframework:spring-test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.echo.artifacts.MessageArtifactTranslator;
import com.netflix.spinnaker.echo.config.AmazonPubsubProperties;
import com.netflix.spinnaker.echo.discovery.DiscoveryActivated;
import com.netflix.spinnaker.echo.pubsub.PubsubEventCreator;
import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler;
import com.netflix.spinnaker.echo.pubsub.PubsubSubscribers;
import com.netflix.spinnaker.echo.pubsub.model.EventCreator;
import com.netflix.spinnaker.echo.pubsub.model.PubsubSubscriber;
import com.netflix.spinnaker.kork.aws.ARN;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -50,7 +50,7 @@
/** * Starts the individual SQS workers (one for each subscription) */
@Component
@ConditionalOnExpression("${pubsub.enabled:false} && ${pubsub.amazon.enabled:false}")
public class SQSSubscriberProvider implements DiscoveryActivated {
public class SQSSubscriberProvider {
private static final Logger log = LoggerFactory.getLogger(SQSSubscriberProvider.class);

private final ObjectMapper objectMapper;
Expand All @@ -61,6 +61,7 @@ public class SQSSubscriberProvider implements DiscoveryActivated {
private final Registry registry;
private final MessageArtifactTranslator.Factory messageArtifactTranslatorFactory;
private final DynamicConfigService dynamicConfigService;
private final DiscoveryStatusListener discoveryStatusListener;

@Autowired
SQSSubscriberProvider(
Expand All @@ -71,7 +72,8 @@ public class SQSSubscriberProvider implements DiscoveryActivated {
PubsubMessageHandler.Factory pubsubMessageHandlerFactory,
Registry registry,
MessageArtifactTranslator.Factory messageArtifactTranslatorFactory,
DynamicConfigService dynamicConfigService) {
DynamicConfigService dynamicConfigService,
DiscoveryStatusListener discoveryStatusListener) {
this.objectMapper = objectMapper;
this.awsCredentialsProvider = awsCredentialsProvider;
this.properties = properties;
Expand All @@ -80,6 +82,7 @@ public class SQSSubscriberProvider implements DiscoveryActivated {
this.registry = registry;
this.messageArtifactTranslatorFactory = messageArtifactTranslatorFactory;
this.dynamicConfigService = dynamicConfigService;
this.discoveryStatusListener = discoveryStatusListener;
}

@PostConstruct
Expand Down Expand Up @@ -145,6 +148,8 @@ public void start() {
}

private Supplier<Boolean> isEnabledSupplier() {
return () -> enabled.get() && dynamicConfigService.isEnabled("pubsub.amazon", true);
return () ->
discoveryStatusListener.isEnabled()
&& dynamicConfigService.isEnabled("pubsub.amazon", true);
}
}
1 change: 0 additions & 1 deletion echo-scheduler/echo-scheduler.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
implementation "com.squareup.okhttp:okhttp-urlconnection"
implementation "com.squareup.okhttp:okhttp-apache"

implementation "com.netflix.eureka:eureka-client"
implementation "com.netflix.spectator:spectator-api"
implementation "com.netflix.spinnaker.kork:kork-artifacts"
implementation "com.netflix.spinnaker.kork:kork-sql"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.netflix.spinnaker.echo.config;

import com.google.common.collect.ImmutableList;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.fiat.shared.EnableFiatAutoConfig;
import com.netflix.spinnaker.filters.AuthenticatedRequestFilter;
Expand Down Expand Up @@ -59,11 +58,6 @@ public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor);
}

@Bean
public InstanceStatus instanceStatus() {
return InstanceStatus.UNKNOWN;
}

@Bean
public FilterRegistrationBean authenticatedRequestFilter() {
FilterRegistrationBean frb =
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fiatVersion=1.21.0
korkVersion=7.50.0
korkVersion=7.51.1
kotlinVersion=1.3.71
org.gradle.parallel=true
spinnakerGradleVersion=8.3.0
Expand Down

0 comments on commit 885722e

Please sign in to comment.