com.simplaex.clients.druid.DruidClient Maven / Gradle / Ivy
package com.simplaex.clients.druid;
import com.metamx.emitter.core.Emitter;
import com.metamx.emitter.core.Event;
import com.simplaex.bedrock.Promise;
import io.druid.query.Query;
import io.druid.query.QueryPlus;
import java.time.Duration;
import java.util.List;
public interface DruidClient extends AutoCloseable {
@FunctionalInterface
interface EventEmitter extends Emitter {
@Override
default void start() {
}
void emit(Event var1);
@Override
default void flush() {
}
@Override
default void close() {
}
}
static DruidClient create(final String hostname, final int port) {
return create(DruidClientConfig.builder().host(hostname).port(port).build());
}
static DruidClient create(final String hostname, final int port, final EventEmitter eventEmitter) {
return new DruidClientImpl(DruidClientConfig.builder().host(hostname).port(port).eventEmitter(eventEmitter).build());
}
static DruidClient create(final DruidClientConfig config) {
return new DruidClientImpl(config);
}
default DruidResult run(final Query query) {
return run(QueryPlus.wrap(query));
}
DruidResult run(QueryPlus queryPlus);
void cancel(DruidResult> druidResult);
default Promise> run(final Query query, final Duration timeout) {
return run(QueryPlus.wrap(query), timeout);
}
Promise> run(QueryPlus queryPlus, Duration timeout);
}