All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.redis.runtime.datasource.ReactiveTransactionalStreamCommandsImpl Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.redis.runtime.datasource;

import java.time.Duration;
import java.util.Map;

import io.quarkus.redis.datasource.stream.ReactiveTransactionalStreamCommands;
import io.quarkus.redis.datasource.stream.StreamRange;
import io.quarkus.redis.datasource.stream.XAddArgs;
import io.quarkus.redis.datasource.stream.XClaimArgs;
import io.quarkus.redis.datasource.stream.XGroupCreateArgs;
import io.quarkus.redis.datasource.stream.XGroupSetIdArgs;
import io.quarkus.redis.datasource.stream.XPendingArgs;
import io.quarkus.redis.datasource.stream.XReadArgs;
import io.quarkus.redis.datasource.stream.XReadGroupArgs;
import io.quarkus.redis.datasource.stream.XTrimArgs;
import io.quarkus.redis.datasource.transactions.ReactiveTransactionalRedisDataSource;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.redis.client.Response;

public class ReactiveTransactionalStreamCommandsImpl extends AbstractTransactionalCommands
        implements ReactiveTransactionalStreamCommands {

    private final ReactiveStreamCommandsImpl reactive;

    public ReactiveTransactionalStreamCommandsImpl(ReactiveTransactionalRedisDataSource ds,
            ReactiveStreamCommandsImpl reactive, TransactionHolder tx) {
        super(ds, tx);
        this.reactive = reactive;
    }

    @Override
    public Uni xack(K key, String group, String... ids) {
        this.tx.enqueue(Response::toInteger);
        return this.reactive._xack(key, group, ids).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xadd(K key, Map payload) {
        this.tx.enqueue(Response::toString);
        return this.reactive._xadd(key, payload).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xadd(K key, XAddArgs args, Map payload) {
        this.tx.enqueue(Response::toString);
        return this.reactive._xadd(key, args, payload).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xautoclaim(K key, String group, String consumer, Duration minIdleTime, String start) {
        this.tx.enqueue(r -> reactive.decodeAsClaimedMessages(key, r));
        return this.reactive._xautoclaim(key, group, consumer, minIdleTime, start).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xautoclaim(K key, String group, String consumer, Duration minIdleTime, String start, int count) {
        this.tx.enqueue(r -> reactive.decodeAsClaimedMessages(key, r));
        return this.reactive._xautoclaim(key, group, consumer, minIdleTime, start, count).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xautoclaim(K key, String group, String consumer, Duration minIdleTime, String start, int count,
            boolean justId) {
        this.tx.enqueue(r -> reactive.decodeAsClaimedMessages(key, r));
        return this.reactive._xautoclaim(key, group, consumer, minIdleTime, start, count, justId).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xclaim(K key, String group, String consumer, Duration minIdleTime, String... id) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xclaim(key, group, consumer, minIdleTime, id).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xclaim(K key, String group, String consumer, Duration minIdleTime, XClaimArgs args, String... id) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xclaim(key, group, consumer, minIdleTime, args, id).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xdel(K key, String... id) {
        this.tx.enqueue(Response::toInteger);
        return this.reactive._xdel(key, id).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupCreate(K key, String groupname, String from) {
        this.tx.enqueue(r -> null);
        return this.reactive._xgroupCreate(key, groupname, from).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupCreate(K key, String groupname, String from, XGroupCreateArgs args) {
        this.tx.enqueue(r -> null);
        return this.reactive._xgroupCreate(key, groupname, from, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupCreateConsumer(K key, String groupname, String consumername) {
        this.tx.enqueue(Response::toBoolean);
        return this.reactive._xgroupCreateConsumer(key, groupname, consumername).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xgroupDelConsumer(K key, String groupname, String consumername) {
        this.tx.enqueue(Response::toLong);
        return this.reactive._xgroupDelConsumer(key, groupname, consumername).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupDestroy(K key, String groupname) {
        this.tx.enqueue(Response::toBoolean);
        return this.reactive._xgroupDestroy(key, groupname).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupSetId(K key, String groupname, String from) {
        this.tx.enqueue(r -> null);
        return this.reactive._xgroupSetId(key, groupname, from).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xgroupSetId(K key, String groupname, String from, XGroupSetIdArgs args) {
        this.tx.enqueue(r -> null);
        return this.reactive._xgroupSetId(key, groupname, from, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xlen(K key) {
        this.tx.enqueue(Response::toLong);
        return this.reactive._xlen(key).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xrange(K key, StreamRange range, int count) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xrange(key, range, count).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xrange(K key, StreamRange range) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xrange(key, range).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xread(K key, String id) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xread(key, id).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xread(Map lastIdsPerStream) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xread(lastIdsPerStream).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xread(K key, String id, XReadArgs args) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xread(key, id, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xread(Map lastIdsPerStream, XReadArgs args) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xread(lastIdsPerStream, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xreadgroup(String group, String consumer, K key, String id) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xreadgroup(group, consumer, key, id).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xreadgroup(String group, String consumer, Map lastIdsPerStream) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xreadgroup(group, consumer, lastIdsPerStream).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xreadgroup(String group, String consumer, K key, String id, XReadGroupArgs args) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xreadgroup(group, consumer, key, id, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xreadgroup(String group, String consumer, Map lastIdsPerStream, XReadGroupArgs args) {
        this.tx.enqueue(r -> reactive.decodeAsListOfMessagesFromXRead(r));
        return this.reactive._xreadgroup(group, consumer, lastIdsPerStream, args).invoke(this::queuedOrDiscard)
                .replaceWithVoid();
    }

    @Override
    public Uni xrevrange(K key, StreamRange range, int count) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xrevrange(key, range, count).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xrevrange(K key, StreamRange range) {
        this.tx.enqueue(r -> reactive.decodeListOfMessages(key, r));
        return this.reactive._xrevrange(key, range).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xtrim(K key, String threshold) {
        this.tx.enqueue(Response::toLong);
        return this.reactive._xtrim(key, new XTrimArgs().minid(threshold)).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xtrim(K key, XTrimArgs args) {
        this.tx.enqueue(Response::toLong);
        return this.reactive._xtrim(key, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xpending(K key, String group) {
        this.tx.enqueue(reactive::decodeAsXPendingSummary);
        return this.reactive._xpending(key, group).invoke(this::queuedOrDiscard).replaceWithVoid();
    }

    @Override
    public Uni xpending(K key, String group, StreamRange range, int count) {
        return this.xpending(key, group, range, count, null);
    }

    @Override
    public Uni xpending(K key, String group, StreamRange range, int count, XPendingArgs args) {
        this.tx.enqueue(reactive::decodeListOfPendingMessages);
        return this.reactive._xpending(key, group, range, count, args).invoke(this::queuedOrDiscard).replaceWithVoid();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy