Java Code Examples for io.micronaut.scheduling.TaskExecutors#IO

The following examples show how to use io.micronaut.scheduling.TaskExecutors#IO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Route53AutoNamingRegistrationClient.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor for setup.
 * @param environment current environemnts
 * @param route53AutoRegistrationConfiguration  config for auto registration
 * @param clientConfiguration general client configuraiton
 * @param amazonComputeInstanceMetadataResolver resolver for aws compute metdata
 * @param executorService this is for executing the thread to monitor the register operation for completion
 * @param awsServiceDiscoveryResolver this allows is to swap out the bean for a mock version for unit testing
 */
protected Route53AutoNamingRegistrationClient(
        Environment environment,
        Route53AutoRegistrationConfiguration route53AutoRegistrationConfiguration,
        AWSClientConfiguration clientConfiguration,
        AmazonComputeInstanceMetadataResolver amazonComputeInstanceMetadataResolver,
        @Named(TaskExecutors.IO) Executor executorService,
        AWSServiceDiscoveryResolver awsServiceDiscoveryResolver) {
    super(route53AutoRegistrationConfiguration);
    this.environment = environment;
    this.route53AutoRegistrationConfiguration = route53AutoRegistrationConfiguration;
    this.clientConfiguration = clientConfiguration;
    this.awsServiceDiscoveryResolver = awsServiceDiscoveryResolver;
    this.amazonComputeInstanceMetadataResolver = amazonComputeInstanceMetadataResolver;
    this.executorService = executorService;
}
 
Example 2
Source File: GrpcServerConfiguration.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param environment The environment
 * @param serverHost The server host
 * @param serverPort The server port
 * @param executorService The IO executor service
 */
public GrpcServerConfiguration(
        Environment environment,
        @Property(name = HOST) @Nullable String serverHost,
        @Property(name = PORT) @Nullable Integer serverPort,
        @Named(TaskExecutors.IO) ExecutorService executorService) {
    this.environment = environment;
    this.serverPort = serverPort != null ? serverPort :
            environment.getActiveNames().contains(Environment.TEST) ? SocketUtils.findAvailableTcpPort() : DEFAULT_PORT;
    this.serverHost = serverHost;
    if (serverHost != null) {
        this.serverBuilder = NettyServerBuilder.forAddress(
                new InetSocketAddress(serverHost, this.serverPort)
        );
    } else {
        this.serverBuilder = NettyServerBuilder.forPort(this.serverPort);
    }
    this.serverBuilder.executor(executorService);
}
 
Example 3
Source File: GrpcServerChannel.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a managed server channel.
 * @param server The server
 * @param executorService The executor service
 * @param clientInterceptors The client interceptors
 * @return The channel
 */
@Singleton
@Named(NAME)
@Requires(beans = GrpcEmbeddedServer.class)
@Bean(preDestroy = "shutdown")
protected ManagedChannel serverChannel(
        GrpcEmbeddedServer server,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService,
        List<ClientInterceptor> clientInterceptors) {
    final ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(
            server.getHost(),
            server.getPort()
    ).executor(executorService);
    if (!server.getServerConfiguration().isSecure()) {
        builder.usePlaintext();
    }
    if (CollectionUtils.isNotEmpty(clientInterceptors)) {
        builder.intercept(clientInterceptors);
    }
    return builder.build();
}
 
Example 4
Source File: GrpcServerConfiguration.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param environment The environment
 * @param serverHost The server host
 * @param serverPort The server port
 * @param executorService The IO executor service
 */
public GrpcServerConfiguration(
        Environment environment,
        @Property(name = HOST) @Nullable String serverHost,
        @Property(name = PORT) @Nullable Integer serverPort,
        @Named(TaskExecutors.IO) ExecutorService executorService) {
    this.environment = environment;
    this.serverPort = serverPort != null ? serverPort :
            environment.getActiveNames().contains(Environment.TEST) ? SocketUtils.findAvailableTcpPort() : DEFAULT_PORT;
    this.serverHost = serverHost;
    if (serverHost != null) {
        this.serverBuilder = NettyServerBuilder.forAddress(
                new InetSocketAddress(serverHost, this.serverPort)
        );
    } else {
        this.serverBuilder = NettyServerBuilder.forPort(this.serverPort);
    }
    this.serverBuilder.executor(executorService);
}
 
Example 5
Source File: GrpcServerChannel.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a managed server channel.
 * @param server The server
 * @param executorService The executor service
 * @param clientInterceptors The client interceptors
 * @return The channel
 */
@Singleton
@Named(NAME)
@Requires(beans = GrpcEmbeddedServer.class)
@Bean(preDestroy = "shutdown")
protected ManagedChannel serverChannel(
        GrpcEmbeddedServer server,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService,
        List<ClientInterceptor> clientInterceptors) {
    final ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(
            server.getHost(),
            server.getPort()
    ).executor(executorService);
    if (!server.getServerConfiguration().isSecure()) {
        builder.usePlaintext();
    }
    if (CollectionUtils.isNotEmpty(clientInterceptors)) {
        builder.intercept(clientInterceptors);
    }
    return builder.build();
}
 
Example 6
Source File: AWSLambdaFunctionExecutor.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * @param asyncClient asyncClient
 * @param byteBufferFactory byteBufferFactory
 * @param jsonMediaTypeCodec jsonMediaTypeCodec
 * @param ioExecutor ioExecutor
 */
protected AWSLambdaFunctionExecutor(
    AWSLambdaAsync asyncClient,
    ByteBufferFactory byteBufferFactory,
    JsonMediaTypeCodec jsonMediaTypeCodec,
    @Named(TaskExecutors.IO) ExecutorService ioExecutor) {

    this.asyncClient = asyncClient;
    this.byteBufferFactory = byteBufferFactory;
    this.jsonMediaTypeCodec = jsonMediaTypeCodec;
    this.ioExecutor = ioExecutor;
}
 
Example 7
Source File: AWSParameterStoreConfigClient.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
/**
 * Execution service to make call to AWS.
 *
 * @param executorService ExecutorService
 */
@Inject
void setExecutionService(@Named(TaskExecutors.IO) @Nullable ExecutorService executorService) {
    if (executorService != null) {
        this.executorService = executorService;
    }
}
 
Example 8
Source File: GrpcChannelBuilderFactory.java    From micronaut-grpc with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 * @param beanContext The bean context
 * @param executorService The I/O executor service
 */
public GrpcChannelBuilderFactory(
        ApplicationContext beanContext,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService) {
    this.beanContext = beanContext;
    this.executorService = executorService;
}
 
Example 9
Source File: GrpcChannelBuilderFactory.java    From micronaut-grpc with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 * @param beanContext The bean context
 * @param executorService The I/O executor service
 */
public GrpcChannelBuilderFactory(
        ApplicationContext beanContext,
        @javax.inject.Named(TaskExecutors.IO) ExecutorService executorService) {
    this.beanContext = beanContext;
    this.executorService = executorService;
}
 
Example 10
Source File: AbstractFlywayMigration.java    From micronaut-flyway with Apache License 2.0 2 votes vote down vote up
/**
 * Run a migration asynchronously.
 *
 * @param config The {@link FlywayConfigurationProperties}
 * @param flyway The {@link Flyway} already configured to run the migrations
 */
@Async(TaskExecutors.IO)
void runAsync(FlywayConfigurationProperties config, Flyway flyway) {
    runFlyway(config, flyway);
}