Skip to content

Commit

Permalink
[#343] wires memory Document collections into CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Jan 9, 2020
1 parent a13c4a7 commit 0128c80
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.icij.datashare.extract.RedisUserDocumentQueue;
import org.icij.datashare.extract.RedisUserDocumentSet;
import org.icij.datashare.tasks.DocumentCollectionFactory;
import org.icij.datashare.tasks.MemoryDocumentCollectionFactory;
import org.icij.datashare.tasks.TaskFactory;
import org.icij.datashare.tasks.TaskManager;
import org.icij.datashare.text.indexing.Indexer;
Expand Down Expand Up @@ -80,10 +81,14 @@ protected void configure() {
bind(Indexer.class).to(ElasticsearchIndexer.class).asEagerSingleton();
bind(TaskManager.class).toInstance(new TaskManager(propertiesProvider));
install(new FactoryModuleBuilder().build(TaskFactory.class));
install(new FactoryModuleBuilder().
if ("memory".equals(propertiesProvider.getProperties().get("queueType"))) {
bind(DocumentCollectionFactory.class).to(MemoryDocumentCollectionFactory.class).asEagerSingleton();
} else {
install(new FactoryModuleBuilder().
implement(DocumentQueue.class, RedisUserDocumentQueue.class).
implement(DocumentSet.class, RedisUserDocumentSet.class).
build(DocumentCollectionFactory.class));
}
bind(Publisher.class).to(RedisPublisher.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public boolean parseArguments(String[] args) {
DatashareCliOptions.queueName(parser);

DatashareCliOptions.cors(parser);
DatashareCliOptions.queueType(parser);
DatashareCliOptions.busType(parser);
DatashareCliOptions.messageBusAddress(parser);
DatashareCliOptions.redisAddress(parser);
DatashareCliOptions.dataSourceUrl(parser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ static OptionSpec<String> messageBusAddress(OptionParser parser) {
.defaultsTo("redis");
}

public static OptionSpec<String> busType(OptionParser parser) {
return parser.acceptsAll(
singletonList("busType"),
"Backend data bus type. Values can be \"memory\" or \"redis\"")
.withRequiredArg()
.defaultsTo("redis");
}

static OptionSpec<String> redisAddress(OptionParser parser) {
return parser.acceptsAll(
singletonList("redisAddress"),
Expand All @@ -137,6 +145,14 @@ static OptionSpec<String> redisAddress(OptionParser parser) {
.defaultsTo("redis://redis:6379");
}

static OptionSpec<String> queueType(OptionParser parser) {
return parser.acceptsAll(
singletonList("queueType"),
"Backend queues and sets type. Values can be \"memory\" or \"redis\"")
.withRequiredArg()
.defaultsTo("redis");
}

static OptionSpec<Integer> fileParserParallelism(OptionParser parser) {
return parser.acceptsAll(
asList("pp", "parserParallelism"),
Expand Down

0 comments on commit 0128c80

Please sign in to comment.