Skip to content

Commit

Permalink
Merge 2627c0a into 1789dfd
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Jul 15, 2021
2 parents 1789dfd + 2627c0a commit 94bf0d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@

import com.agorapulse.micronaut.segment.builder.*;
import com.segment.analytics.Analytics;
import io.micronaut.context.annotation.Requires;

import javax.inject.Singleton;
import java.util.function.Consumer;
import java.util.function.Supplier;

@Singleton
@Requires(beans = com.segment.analytics.Analytics.class)
public class DefaultSegmentService implements SegmentService {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@
import com.agorapulse.micronaut.segment.builder.MessageBuilderWithProperties;
import com.agorapulse.micronaut.segment.builder.MessageBuilderWithTraits;
import com.agorapulse.micronaut.segment.builder.SimpleMessageBuilder;
import com.segment.analytics.Analytics;
import io.micronaut.context.annotation.Requires;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Singleton;
import java.util.function.Consumer;

@Singleton
@Requires(missingBeans = {Analytics.class})
public class NoOpSegmentService implements SegmentService {

private static final Logger LOGGER = LoggerFactory.getLogger(NoOpSegmentService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Requires;

import javax.annotation.Nullable;
import javax.inject.Singleton;
import java.util.List;

Expand All @@ -44,4 +45,13 @@ public Analytics analytics(
return builder.build();
}

@Bean
@Singleton
public SegmentService segmentService(@Nullable Analytics analytics, @Nullable SegmentConfiguration configuration) {
if (analytics != null) {
return new DefaultSegmentService(analytics, configuration);
}
return new NoOpSegmentService();
}

}

0 comments on commit 94bf0d8

Please sign in to comment.