use of com.lambdaworks.redis.codec.ByteArrayCodec in project moleculer-java by moleculer-java.
the class RedisPubSubClient method connect.
// --- CONNECT ---
public final void connect() {
DefaultClientResources.Builder builder = DefaultClientResources.builder();
acceptor = Executors.newSingleThreadExecutor();
group = new NioEventLoopGroup(1, acceptor);
builder.eventLoopGroupProvider(new EventLoopGroupProvider() {
@Override
public final int threadPoolSize() {
return 1;
}
@Override
public final Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) {
return null;
}
@Override
public final Future<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {
return null;
}
@SuppressWarnings("unchecked")
@Override
public final <T extends EventLoopGroup> T allocate(Class<T> type) {
return (T) group;
}
});
builder.eventExecutorGroup(new DefaultEventExecutor(executor));
if (eventBus == null) {
builder.eventBus(new EventBus() {
@Override
public final void publish(Event event) {
}
@Override
public final Observable<Event> get() {
return null;
}
});
} else {
builder.eventBus(eventBus);
}
resources = builder.build();
List<RedisURI> redisURIs = parseURLs(urls, password, secure);
StatefulRedisPubSubConnection<byte[], byte[]> connection;
ByteArrayCodec codec = new ByteArrayCodec();
if (urls.length > 1) {
// Clustered client
connection = RedisClusterClient.create(resources, redisURIs).connectPubSub(codec);
} else {
// Single connection
connection = RedisClient.create(resources, redisURIs.get(0)).connectPubSub(codec);
}
// Add listener
if (listener != null) {
connection.addListener(listener);
}
commands = connection.async();
}
use of com.lambdaworks.redis.codec.ByteArrayCodec in project moleculer-java by moleculer-java.
the class RedisGetSetClient method connect.
// --- CONNECT ---
public final void connect() {
DefaultClientResources.Builder builder = DefaultClientResources.builder();
acceptor = Executors.newSingleThreadExecutor();
group = new NioEventLoopGroup(1, acceptor);
builder.eventLoopGroupProvider(new EventLoopGroupProvider() {
@Override
public final int threadPoolSize() {
return 1;
}
@Override
public final Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) {
return null;
}
@Override
public final Future<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {
return null;
}
@SuppressWarnings("unchecked")
@Override
public final <T extends EventLoopGroup> T allocate(Class<T> type) {
return (T) group;
}
});
builder.eventExecutorGroup(new DefaultEventExecutor(executor));
if (eventBus == null) {
builder.eventBus(new EventBus() {
@Override
public final void publish(Event event) {
}
@Override
public final Observable<Event> get() {
return null;
}
});
} else {
builder.eventBus(eventBus);
}
resources = builder.build();
List<RedisURI> redisURIs = parseURLs(urls, password, secure);
ByteArrayCodec codec = new ByteArrayCodec();
if (urls.length > 1) {
// Clustered client
clusteredClient = RedisClusterClient.create(resources, redisURIs).connect(codec).async();
} else {
// Single server connection
client = RedisClient.create(resources, redisURIs.get(0)).connect(codec).async();
}
}
Aggregations