io.quarkus.amazon.ses.runtime.SesRecorder Maven / Gradle / Ivy
package io.quarkus.amazon.ses.runtime;
import io.quarkus.amazon.common.runtime.AwsConfig;
import io.quarkus.amazon.common.runtime.NettyHttpClientConfig;
import io.quarkus.amazon.common.runtime.SdkConfig;
import io.quarkus.amazon.common.runtime.SyncHttpClientConfig;
import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
import software.amazon.awssdk.services.ses.SesAsyncClient;
import software.amazon.awssdk.services.ses.SesAsyncClientBuilder;
import software.amazon.awssdk.services.ses.SesClient;
import software.amazon.awssdk.services.ses.SesClientBuilder;
@Recorder
public class SesRecorder {
public RuntimeValue getSyncConfig(SesConfig config) {
return new RuntimeValue<>(config.syncClient);
}
public RuntimeValue getAsyncConfig(SesConfig config) {
return new RuntimeValue<>(config.asyncClient);
}
public RuntimeValue getAwsConfig(SesConfig config) {
return new RuntimeValue<>(config.aws);
}
public RuntimeValue getSdkConfig(SesConfig config) {
return new RuntimeValue<>(config.sdk);
}
public RuntimeValue createSyncBuilder(SesConfig config, RuntimeValue transport) {
SesClientBuilder builder = SesClient.builder();
if (transport != null) {
builder.httpClientBuilder(transport.getValue());
}
return new RuntimeValue<>(builder);
}
public RuntimeValue createAsyncBuilder(SesConfig config,
RuntimeValue transport) {
SesAsyncClientBuilder builder = SesAsyncClient.builder();
if (transport != null) {
builder.httpClientBuilder(transport.getValue());
}
return new RuntimeValue<>(builder);
}
public RuntimeValue buildClient(RuntimeValue extends AwsClientBuilder> builder,
BeanContainer beanContainer,
ShutdownContext shutdown) {
SesClientProducer producer = beanContainer.instance(SesClientProducer.class);
producer.setSyncConfiguredBuilder((SesClientBuilder) builder.getValue());
shutdown.addShutdownTask(producer::destroy);
return new RuntimeValue<>(producer.client());
}
public RuntimeValue buildAsyncClient(RuntimeValue extends AwsClientBuilder> builder,
BeanContainer beanContainer,
ShutdownContext shutdown) {
SesClientProducer producer = beanContainer.instance(SesClientProducer.class);
producer.setAsyncConfiguredBuilder((SesAsyncClientBuilder) builder.getValue());
shutdown.addShutdownTask(producer::destroy);
return new RuntimeValue<>(producer.asyncClient());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy