Search in sources :

Example 1 with SwfClientBuilder

use of software.amazon.awssdk.services.swf.SwfClientBuilder in project flux-swf-client by awslabs.

the class FluxCapacitorImpl method getRemoteWorkflowExecutor.

@Override
public RemoteWorkflowExecutor getRemoteWorkflowExecutor(String swfRegion, String swfEndpoint, AwsCredentialsProvider credentials, String workflowDomain) {
    // for the regular FluxCapacitor SwfClient, we disabled all the retry logic
    // since we do our own for metrics purposes. However the remote client is not used
    // for much, and we don't bother emitting metrics for it, so the defaults are fine.
    // this is where we'd add an execution interceptor for e.g. SDK metrics
    ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().build();
    SwfClientBuilder customSwf = SwfClient.builder().credentialsProvider(credentials).region(Region.of(swfRegion)).overrideConfiguration(overrideConfig);
    if (swfEndpoint != null) {
        customSwf.endpointOverride(URI.create(swfEndpoint));
    }
    return new RemoteWorkflowExecutorImpl(metricsFactory, workflowsByName, customSwf.build(), workflowDomain);
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder)

Example 2 with SwfClientBuilder

use of software.amazon.awssdk.services.swf.SwfClientBuilder in project flux-swf-client by awslabs.

the class FluxCapacitorImpl method create.

/**
 * Creates a FluxCapacitor object and does various bits of setup e.g. registering the swf domain.
 * Intentionally package-private, only the Factory should be using the constructor.
 *
 * @param metricsFactory - A factory that produces MetricRecorder objects for emitting workflow metrics.
 * @param credentials    - A provider for the AWS credentials that should be used to call SWF APIs
 * @param config         - Configuration data for FluxCapacitor to use to configure itself
 */
static FluxCapacitor create(MetricRecorderFactory metricsFactory, AwsCredentialsProvider credentials, FluxCapacitorConfig config) {
    // We do our own retry/backoff logic so we can get decent metrics, so here we disable the SDK's defaults.
    RetryPolicy retryPolicy = RetryPolicy.builder().retryCondition(RetryCondition.none()).numRetries(0).backoffStrategy(BackoffStrategy.none()).throttlingBackoffStrategy(BackoffStrategy.none()).build();
    // If an override config was provided, use it, and only use the above RetryPolicy
    // if the provided overrideConfig did not include its own RetryPolicy.
    ClientOverrideConfiguration overrideConfig = config.getClientOverrideConfiguration();
    if (overrideConfig == null) {
        overrideConfig = ClientOverrideConfiguration.builder().retryPolicy(retryPolicy).build();
    } else if (!overrideConfig.retryPolicy().isPresent()) {
        overrideConfig = overrideConfig.toBuilder().retryPolicy(retryPolicy).build();
    }
    SwfClientBuilder builder = SwfClient.builder().credentialsProvider(credentials).region(Region.of(config.getAwsRegion())).overrideConfiguration(overrideConfig);
    // otherwise the SDK will figure it out based on the region name.
    if (config.getSwfEndpoint() != null && !"".equals(config.getSwfEndpoint())) {
        builder.endpointOverride(URI.create(config.getSwfEndpoint()));
    }
    return new FluxCapacitorImpl(metricsFactory, builder.build(), config);
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy)

Example 3 with SwfClientBuilder

use of software.amazon.awssdk.services.swf.SwfClientBuilder in project flux-swf-client by danielgmyers.

the class FluxCapacitorImpl method create.

/**
 * Creates a FluxCapacitor object and does various bits of setup e.g. registering the swf domain.
 * Intentionally package-private, only the Factory should be using the constructor.
 *
 * @param metricsFactory - A factory that produces MetricRecorder objects for emitting workflow metrics.
 * @param credentials    - A provider for the AWS credentials that should be used to call SWF APIs
 * @param config         - Configuration data for FluxCapacitor to use to configure itself
 */
static FluxCapacitor create(MetricRecorderFactory metricsFactory, AwsCredentialsProvider credentials, FluxCapacitorConfig config) {
    // We do our own retry/backoff logic so we can get decent metrics, so here we disable the SDK's defaults.
    RetryPolicy retryPolicy = RetryPolicy.builder().retryCondition(RetryCondition.none()).numRetries(0).backoffStrategy(BackoffStrategy.none()).throttlingBackoffStrategy(BackoffStrategy.none()).build();
    // If an override config was provided, use it, and only use the above RetryPolicy
    // if the provided overrideConfig did not include its own RetryPolicy.
    ClientOverrideConfiguration overrideConfig = config.getClientOverrideConfiguration();
    if (overrideConfig == null) {
        overrideConfig = ClientOverrideConfiguration.builder().retryPolicy(retryPolicy).build();
    } else if (!overrideConfig.retryPolicy().isPresent()) {
        overrideConfig = overrideConfig.toBuilder().retryPolicy(retryPolicy).build();
    }
    SwfClientBuilder builder = SwfClient.builder().credentialsProvider(credentials).region(Region.of(config.getAwsRegion())).overrideConfiguration(overrideConfig);
    // otherwise the SDK will figure it out based on the region name.
    if (config.getSwfEndpoint() != null && !"".equals(config.getSwfEndpoint())) {
        builder.endpointOverride(URI.create(config.getSwfEndpoint()));
    }
    return new FluxCapacitorImpl(metricsFactory, builder.build(), config, Clock.systemUTC());
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy)

Example 4 with SwfClientBuilder

use of software.amazon.awssdk.services.swf.SwfClientBuilder in project flux-swf-client by danielgmyers.

the class FluxCapacitorImpl method getRemoteWorkflowExecutor.

@Override
public RemoteWorkflowExecutor getRemoteWorkflowExecutor(String swfRegion, String swfEndpoint, AwsCredentialsProvider credentials, String workflowDomain) {
    // for the regular FluxCapacitor SwfClient, we disabled all the retry logic
    // since we do our own for metrics purposes. However the remote client is not used
    // for much, and we don't bother emitting metrics for it, so the defaults are fine.
    // this is where we'd add an execution interceptor for e.g. SDK metrics
    ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().build();
    SwfClientBuilder customSwf = SwfClient.builder().credentialsProvider(credentials).region(Region.of(swfRegion)).overrideConfiguration(overrideConfig);
    if (swfEndpoint != null) {
        customSwf.endpointOverride(URI.create(swfEndpoint));
    }
    return new RemoteWorkflowExecutorImpl(metricsFactory, workflowsByName, customSwf.build(), workflowDomain);
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder)

Aggregations

ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)4 SwfClientBuilder (software.amazon.awssdk.services.swf.SwfClientBuilder)4 RetryPolicy (software.amazon.awssdk.core.retry.RetryPolicy)2