com.instaclustr.operations.OperationsModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common classes and utilities integrated with various projects
package com.instaclustr.operations;
import static java.util.concurrent.TimeUnit.HOURS;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
import com.instaclustr.guice.ServiceBindings;
import com.instaclustr.measure.Time;
public class OperationsModule extends AbstractModule {
private static final Time DEFAULT_OPERATIONS_EXPIRATION_PERIOD = new Time((long) 1, HOURS);
private final long operationsExpirationPeriod;
public OperationsModule() {
this(DEFAULT_OPERATIONS_EXPIRATION_PERIOD);
}
public OperationsModule(final Time operationsExpirationPeriod) {
this(operationsExpirationPeriod.asSeconds().value);
}
public OperationsModule(final long operationsExpirationPeriod) {
this.operationsExpirationPeriod = operationsExpirationPeriod;
}
@Override
protected void configure() {
ServiceBindings.bindService(binder(), OperationsService.class);
ServiceBindings.bindService(binder(), OperationsExpirationService.class);
// synchronised as this map will be used in both OperationsService and OperationsExpirationService
// LinkedHashMap as this will preserve order in which they were added
bind(new TypeLiteral