Skip to content

Commit

Permalink
refactor: return info map as unmodifiable map in Metrics (#66)
Browse files Browse the repository at this point in the history
* refactor: return info map as unmodifiable map in Metrics

* refactor: remove the property and inject on method directly
  • Loading branch information
anandmnair authored Aug 17, 2023
1 parent d4ec685 commit 47dceb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.societegenerale.failover.core.report;

import lombok.Data;
import lombok.Getter;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -32,10 +32,8 @@ public class Metrics {

private static final String KEY_PREFIX = "failover";

@Getter
private String name;

@Getter
private Map<String, String> info;

private String keyPrefix;
Expand All @@ -54,4 +52,8 @@ public Metrics collect(String key, String value) {
info.put( format("%s-%s",keyPrefix, key), value);
return this;
}

public Map<String, String> getInfo() {
return Collections.unmodifiableMap(info);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.societegenerale.failover.scheduler.ReportScheduler;
import com.societegenerale.failover.store.FailoverStoreAsync;
import com.societegenerale.failover.store.FailoverStoreInmemory;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
Expand All @@ -83,15 +82,12 @@
@ConditionalOnExpression("${failover.enabled:true} eq true")
@EnableConfigurationProperties(FailoverProperties.class)
@Configuration
@AllArgsConstructor
@Slf4j
@EnableAspectJAutoProxy
@EnableAsync
@EnableScheduling
public class FailoverAutoConfiguration {

private FailoverProperties failoverProperties;

@ConditionalOnMissingBean
@Bean
public FailoverClock failoverClock() {
Expand Down Expand Up @@ -148,7 +144,7 @@ public PayloadEnricher<Object> payloadEnricher() {

@ConditionalOnMissingBean
@Bean
public FailoverScanner failoverScanner() {
public FailoverScanner failoverScanner(FailoverProperties failoverProperties) {
return new DefaultFailoverScanner(failoverProperties.getPackageToScan());
}

Expand Down Expand Up @@ -216,7 +212,7 @@ public ManifestInfoExtractor manifestInfoExtractor(ResourceLoader resourceLoader

@ConditionalOnMissingBean
@Bean(initMethod = "report")
public FailoverReporter failoverReporter(CompositeReportPublisher reportPublisher, FailoverScanner failoverScanner, FailoverClock clock, ManifestInfoExtractor manifestInfoExtractor, FailoverExpiryExtractor failoverExpiryExtractor) {
public FailoverReporter failoverReporter(CompositeReportPublisher reportPublisher, FailoverScanner failoverScanner, FailoverClock clock, ManifestInfoExtractor manifestInfoExtractor, FailoverExpiryExtractor failoverExpiryExtractor, FailoverProperties failoverProperties) {
return new DefaultFailoverReporter(reportPublisher, failoverScanner, clock, manifestInfoExtractor, failoverExpiryExtractor, failoverProperties.additionalInfo());
}

Expand Down

0 comments on commit 47dceb3

Please sign in to comment.