Refine search
@Override public ClientResponse.Builder body(String body) { Assert.notNull(body, "Body must not be null"); releaseBody(); DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); this.body = Flux.just(body). map(s -> { byte[] bytes = body.getBytes(StandardCharsets.UTF_8); return dataBufferFactory.wrap(bytes); }); return this; }
@Override public ServerRequest.Builder body(String body) { Assert.notNull(body, "Body must not be null"); releaseBody(); DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); this.body = Flux.just(body). map(s -> { byte[] bytes = body.getBytes(StandardCharsets.UTF_8); return dataBufferFactory.wrap(bytes); }); return this; }
/** * Relay buffers from the given {@link Publisher} until the total * {@linkplain DataBuffer#readableByteCount() byte count} reaches * the given maximum byte count, or until the publisher is complete. * @param publisher the publisher to filter * @param maxByteCount the maximum byte count * @return a flux whose maximum byte count is {@code maxByteCount} */ public static Flux<DataBuffer> takeUntilByteCount(Publisher<DataBuffer> publisher, long maxByteCount) { Assert.notNull(publisher, "Publisher must not be null"); Assert.isTrue(maxByteCount >= 0, "'maxByteCount' must be a positive number"); return Flux.defer(() -> { AtomicLong countDown = new AtomicLong(maxByteCount); return Flux.from(publisher) .map(buffer -> { long remainder = countDown.addAndGet(-buffer.readableByteCount()); if (remainder < 0) { int length = buffer.readableByteCount() + (int) remainder; return buffer.slice(0, length); } else { return buffer; } }) .takeUntil(buffer -> countDown.get() <= 0); }); // no doOnDiscard necessary, as this method does not drop buffers }
@Override public Flux<V> reverseRangeByLex(K key, Range<String> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return createFlux(connection -> connection.zRevRangeByLex(rawKey(key), range, limit).map(this::readValue)); }
@Override public Flux<TypedTuple<V>> reverseRangeByScoreWithScores(K key, Range<Double> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return createFlux( connection -> connection.zRevRangeByScoreWithScores(rawKey(key), range, limit).map(this::readTypedTuple)); }
@Override public Flux<MapRecord<K, HK, HV>> range(K key, Range<String> range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); Assert.notNull(limit, "Limit must not be null!"); return createFlux(connection -> connection.xRange(rawKey(key), range, limit).map(this::deserializeRecord)); }
@Override public Flux<TypedTuple<V>> reverseRangeByScoreWithScores(K key, Range<Double> range) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); return createFlux( connection -> connection.zRevRangeByScoreWithScores(rawKey(key), range).map(this::readTypedTuple)); }
@Override public Flux<MapRecord<K, HK, HV>> read(StreamReadOptions readOptions, StreamOffset<K>... streams) { Assert.notNull(readOptions, "StreamReadOptions must not be null!"); Assert.notNull(streams, "Streams must not be null!"); return createFlux(connection -> { StreamOffset<ByteBuffer>[] streamOffsets = rawStreamOffsets(streams); return connection.xRead(readOptions, streamOffsets).map(this::deserializeRecord); }); }
@Override public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance, GeoRadiusCommandArgs args) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(member, "Member must not be null!"); Assert.notNull(distance, "Distance must not be null!"); Assert.notNull(args, "GeoRadiusCommandArgs must not be null!"); return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance, args)) .map(this::readGeoResult); }
ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) { Assert.notNull(inputStream, "'inputStream' must not be null"); Assert.notNull(bufferFactory, "'bufferFactory' must not be null"); Assert.notNull(elementType, "'elementType' must not be null"); byte[] separator = STREAM_SEPARATORS.getOrDefault(mediaType, NEWLINE_SEPARATOR); return Flux.from(inputStream).map(value -> { DataBuffer buffer = encodeValue(value, mimeType, bufferFactory, elementType, hints,
@Override public Mono<List<HV>> multiGet(H key, Collection<HK> hashKeys) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(hashKeys, "Hash keys must not be null!"); Assert.notEmpty(hashKeys, "Hash keys must not be empty!"); return createMono(connection -> Flux.fromIterable(hashKeys) // .map(this::rawHashKey) // .collectList() // .flatMap(hks -> connection.hMGet(rawKey(key), hks)).map(this::deserializeHashValues)); }
@Override public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(member, "Member must not be null!"); Assert.notNull(distance, "Distance must not be null!"); return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance) // .map(this::readGeoResult)); }