Using lombok annotations to replace setters in the Worker.Builder.
This commit is contained in:
parent
d4c90b8748
commit
e2c7d7f2c7
1 changed files with 10 additions and 105 deletions
|
|
@ -33,6 +33,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import com.amazonaws.services.kinesis.clientlibrary.proxies.IKinesisProxy;
|
import com.amazonaws.services.kinesis.clientlibrary.proxies.IKinesisProxy;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
@ -1070,22 +1072,23 @@ public class Worker implements Runnable {
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private IRecordProcessorFactory recordProcessorFactory;
|
private IRecordProcessorFactory recordProcessorFactory;
|
||||||
private RecordsFetcherFactory recordsFetcherFactory;
|
@Setter @Accessors(fluent = true)
|
||||||
private KinesisClientLibConfiguration config;
|
private KinesisClientLibConfiguration config;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private AmazonKinesis kinesisClient;
|
private AmazonKinesis kinesisClient;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private AmazonDynamoDB dynamoDBClient;
|
private AmazonDynamoDB dynamoDBClient;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private AmazonCloudWatch cloudWatchClient;
|
private AmazonCloudWatch cloudWatchClient;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private IMetricsFactory metricsFactory;
|
private IMetricsFactory metricsFactory;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private ExecutorService execService;
|
private ExecutorService execService;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private ShardPrioritization shardPrioritization;
|
private ShardPrioritization shardPrioritization;
|
||||||
|
@Setter @Accessors(fluent = true)
|
||||||
private IKinesisProxy kinesisProxy;
|
private IKinesisProxy kinesisProxy;
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
public Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a V1 {@link com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor
|
* Provide a V1 {@link com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor
|
||||||
* IRecordProcessor}.
|
* IRecordProcessor}.
|
||||||
|
|
@ -1113,104 +1116,6 @@ public class Worker implements Runnable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Worker config.
|
|
||||||
*
|
|
||||||
* @param config
|
|
||||||
* Kinesis Client Library configuration
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder config(KinesisClientLibConfiguration config) {
|
|
||||||
this.config = config;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Kinesis client.
|
|
||||||
*
|
|
||||||
* @param kinesisClient
|
|
||||||
* Kinesis Client used for fetching data
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder kinesisClient(AmazonKinesis kinesisClient) {
|
|
||||||
this.kinesisClient = kinesisClient;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the DynamoDB client.
|
|
||||||
*
|
|
||||||
* @param dynamoDBClient
|
|
||||||
* DynamoDB client used for checkpoints and tracking leases
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder dynamoDBClient(AmazonDynamoDB dynamoDBClient) {
|
|
||||||
this.dynamoDBClient = dynamoDBClient;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the Cloudwatch client.
|
|
||||||
*
|
|
||||||
* @param cloudWatchClient
|
|
||||||
* CloudWatch Client for publishing metrics
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder cloudWatchClient(AmazonCloudWatch cloudWatchClient) {
|
|
||||||
this.cloudWatchClient = cloudWatchClient;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the metrics factory.
|
|
||||||
*
|
|
||||||
* @param metricsFactory
|
|
||||||
* Metrics factory used to emit metrics
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder metricsFactory(IMetricsFactory metricsFactory) {
|
|
||||||
this.metricsFactory = metricsFactory;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the executor service for processing records.
|
|
||||||
*
|
|
||||||
* @param execService
|
|
||||||
* ExecutorService to use for processing records (support for multi-threaded consumption)
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder execService(ExecutorService execService) {
|
|
||||||
this.execService = execService;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides logic how to prioritize shard processing.
|
|
||||||
*
|
|
||||||
* @param shardPrioritization
|
|
||||||
* shardPrioritization is responsible to order shards before processing
|
|
||||||
*
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder shardPrioritization(ShardPrioritization shardPrioritization) {
|
|
||||||
this.shardPrioritization = shardPrioritization;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set KinesisProxy for the worker.
|
|
||||||
*
|
|
||||||
* @param kinesisProxy
|
|
||||||
* Sets an implementation of IKinesisProxy.
|
|
||||||
*
|
|
||||||
* @return A reference to this updated object so that method calls can be chained together.
|
|
||||||
*/
|
|
||||||
public Builder kinesisProxy(IKinesisProxy kinesisProxy) {
|
|
||||||
this.kinesisProxy = kinesisProxy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the Worker instance.
|
* Build the Worker instance.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue