get all previous keys on a range in jetcd

66 Views Asked by At
WatchOption watchOption = WatchOption.newBuilder()
                .withRange(OptionsUtil.prefixEndOf(key))
                .withPrevKV(true)
                .isPrefix(true)
                .build();

I have a watch option like this, how can I get the previous state of all the kvs before the watchEvent? WatchEvent.getPrev() only gives me one previous value corresponding to the event and if I query inside a listener lambda the query gets deadlocked (I suspect?)

//this times out if executed as part of the consumer of WatchResponse
            GetOption option = GetOption.newBuilder()
                    .withRange(ByteSequence.from(KEY_PATH, StandardCharsets.UTF_8))
                    .isPrefix(true)
                    .build();
            GetResponse getResponse =  client.getKVClient().get(prefixBytes, option).get(timeout, TimeUnit.SECONDS);ETCD_REQUEST_TIMEOUT);
0

There are 0 best solutions below