Skip to content

Commit

Permalink
refactor(plugins): Consolidate plugins monitor config (#727)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Smalley <csmalley@netflix.com>
  • Loading branch information
robzienert and jonsie committed May 6, 2020
1 parent 834d1a8 commit 50d320a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ protected void commitDelta(PluginPollingDelta delta, boolean sendEvents) {
private void postEvent(PluginRelease release) {
if (!echoService.isPresent()) {
log.warn("Cannot send new plugin notification: Echo is not configured");
registry.counter(
missedNotificationId.withTag("monitor", PluginsBuildMonitor.class.getSimpleName()));
registry
.counter(
missedNotificationId.withTag("monitor", PluginsBuildMonitor.class.getSimpleName()))
.increment();
} else if (release != null) {
AuthenticatedRequest.allowAnonymous(
() -> echoService.get().postEvent(new PluginEvent(release)));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.config.OkHttpClientConfiguration;
import com.netflix.spinnaker.igor.IgorConfigurationProperties;
import com.netflix.spinnaker.igor.history.EchoService;
import com.netflix.spinnaker.igor.plugins.PluginCache;
Expand All @@ -27,13 +28,18 @@
import com.netflix.spinnaker.igor.polling.LockService;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate;
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger;
import com.squareup.okhttp.OkHttpClient;
import java.util.Optional;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit.Endpoints;
import retrofit.RestAdapter;
import retrofit.client.OkClient;

@Configuration
@ConditionalOnBean(Front50Service.class)
@ConditionalOnProperty("services.front50.base-url")
public class PluginMonitorConfig {

@Bean
Expand All @@ -43,7 +49,21 @@ public PluginCache pluginCache(
}

@Bean
public PluginReleaseService pluginReleaseService(Front50Service front50Service) {
public PluginReleaseService pluginReleaseService(
OkHttpClientConfiguration okHttpClientConfiguration, IgorConfigurationProperties properties) {
String address = properties.getServices().getFront50().getBaseUrl();

OkHttpClient client = okHttpClientConfiguration.create();

Front50Service front50Service =
new RestAdapter.Builder()
.setEndpoint(Endpoints.newFixedEndpoint(address))
.setClient(new OkClient(client))
.setLogLevel(RestAdapter.LogLevel.BASIC)
.setLog(new Slf4jRetrofitLogger(Front50Service.class))
.build()
.create(Front50Service.class);

return new PluginReleaseService(front50Service);
}

Expand Down

0 comments on commit 50d320a

Please sign in to comment.