use of io.micronaut.core.annotation.NonNull in project micronaut-kafka by micronaut-projects.
the class KafkaConsumerProcessor method getConsumer.
@NonNull
@Override
public <K, V> Consumer<K, V> getConsumer(@NonNull String id) {
ArgumentUtils.requireNonNull("id", id);
final Consumer consumer = getConsumerState(id).kafkaConsumer;
if (consumer == null) {
throw new IllegalArgumentException("No consumer found for ID: " + id);
}
return consumer;
}
use of io.micronaut.core.annotation.NonNull in project micronaut-gcp by micronaut-projects.
the class DefaultPublisherFactory method createPublisher.
/**
* Creates a publisher for a given topic.
*
* @param config {@link PublisherFactoryConfig} object containing all required properties.
* @return An instance of {@link Publisher} configured using the config and environment properties from `gcp.pubsub.publisher.>config_name<`
*/
@Override
public Publisher createPublisher(@NonNull PublisherFactoryConfig config) {
try {
Publisher.Builder publisherBuilder = Publisher.newBuilder(config.getTopicState().getProjectTopicName());
Optional<PublisherConfigurationProperties> publisherConfiguration = beanContext.findBean(PublisherConfigurationProperties.class, Qualifiers.byName(config.getTopicState().getConfigurationName()));
String executor = publisherConfiguration.map(p -> p.getExecutor()).orElse(config.getDefaultExecutor());
ExecutorService executorService = beanContext.getBean(ExecutorService.class, Qualifiers.byName(executor));
publisherBuilder.setEnableMessageOrdering(config.getTopicState().getOrdered());
if (!StringUtils.isEmpty(config.getTopicState().getEndpoint())) {
publisherBuilder.setEndpoint(config.getTopicState().getEndpoint());
}
if (publisherConfiguration.isPresent()) {
publisherBuilder.setRetrySettings(publisherConfiguration.get().getRetrySettings().build());
// FlowControl had to be flatten in order to be parsed
BatchingSettings batchSettings = publisherConfiguration.get().getBatchingSettings().build();
publisherBuilder.setBatchingSettings(BatchingSettings.newBuilder().setDelayThreshold(batchSettings.getDelayThreshold()).setElementCountThreshold(batchSettings.getElementCountThreshold()).setIsEnabled(batchSettings.getIsEnabled()).setRequestByteThreshold(batchSettings.getRequestByteThreshold()).setFlowControlSettings(publisherConfiguration.get().getFlowControlSettings().build()).build());
}
if (!(executorService instanceof ScheduledExecutorService)) {
throw new IllegalStateException("Invalid Executor type provided, please make sure you have a ScheduledExecutorService configured for Publisher: " + config.getTopicState().getProjectTopicName().getTopic());
}
publisherBuilder.setExecutorProvider(FixedExecutorProvider.create((ScheduledExecutorService) executorService));
publisherBuilder.setChannelProvider(this.transportChannelProvider);
publisherBuilder.setCredentialsProvider(this.credentialsProvider);
return publisherBuilder.build();
} catch (Exception ex) {
throw new PubSubClientException("Failed to create subscriber", ex);
}
}
use of io.micronaut.core.annotation.NonNull in project micronaut-gcp by micronaut-projects.
the class GoogleFunctionHttpRequest method getCookies.
@NonNull
@Override
public Cookies getCookies() {
ServletCookies cookies = this.cookies;
if (cookies == null) {
synchronized (this) {
// double check
cookies = this.cookies;
if (cookies == null) {
cookies = new ServletCookies(getPath(), getHeaders(), ConversionService.SHARED);
this.cookies = cookies;
}
}
}
return cookies;
}
use of io.micronaut.core.annotation.NonNull in project micronaut-gcp by micronaut-projects.
the class HttpFunction method newApplicationContextBuilder.
@NonNull
@Override
protected ApplicationContextBuilder newApplicationContextBuilder() {
final ApplicationContextBuilder builder = super.newApplicationContextBuilder();
builder.deduceEnvironment(false);
builder.environments(Environment.FUNCTION, Environment.GOOGLE_COMPUTE);
return builder;
}
use of io.micronaut.core.annotation.NonNull in project micronaut-security by micronaut-projects.
the class EndSessionEndpointResolver method oktaEndSessionEndpoint.
@NonNull
private Optional<EndSessionEndpoint> oktaEndSessionEndpoint(OauthClientConfiguration oauthClientConfiguration, Supplier<OpenIdProviderMetadata> openIdProviderMetadata, EndSessionCallbackUrlBuilder endSessionCallbackUrlBuilder) {
SecurityConfiguration securityConfiguration = beanContext.getBean(SecurityConfiguration.class);
TokenResolver tokenResolver = beanContext.getBean(TokenResolver.class);
return Optional.of(new OktaEndSessionEndpoint(endSessionCallbackUrlBuilder, oauthClientConfiguration, openIdProviderMetadata, securityConfiguration, tokenResolver));
}
Aggregations