Interface ChunkResponseParser<H extends ChunkHeader,ROW extends ChunkRow,T extends ChunkTrailer>
- All Known Implementing Classes:
AnalyticsChunkResponseParser,BaseChunkResponseParser,QueryChunkResponseParser,SearchChunkResponseParser,ViewChunkResponseParser
public interface ChunkResponseParser<H extends ChunkHeader,ROW extends ChunkRow,T extends ChunkTrailer>
Defines the common parser interface for all chunked response parser implementations.
-
Method Summary
Modifier and Type Method Description voidcleanup()Releases resources managed by the parser and prepares it for reuse.Optional<CouchbaseException>decodingFailure()If the parser fails due to malformed input the cause is returned here.voidendOfInput()Indicates the complete JSON document has been fed to the parser.Optional<CouchbaseException>error()If the parser sees an error, it should fill this optional so that if the IO layer needs to fail the topmost future it will be passed in.voidfeed(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf input)Parses the given JSON document fragment.Optional<H>header(boolean lastChunk)Once the header is completely available, returns a non-absent value of it.voidinitialize(com.couchbase.client.core.deps.io.netty.channel.ChannelConfig channelConfig)Begins a new parsing session.Flux<ROW>rows()Returns the currently assigned flux for the rows.Mono<T>trailer()Returns the currently assigned mono for the trailer bits.voidupdateRequestContext(RequestContext requestContext)Sets the request context for the current request in the parser, can be used for error handling.voidupdateResponseHeader(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse responseHeader)Sets the current response header if present.
-
Method Details
-
header
Once the header is completely available, returns a non-absent value of it.It is important to provide a non-absent value even if some parts are optional because the related IO components will only proceed if a header is available eventually.
- Parameters:
lastChunk- if we are currently parsing the last chunk.
-
error
Optional<CouchbaseException> error()If the parser sees an error, it should fill this optional so that if the IO layer needs to fail the topmost future it will be passed in. -
decodingFailure
Optional<CouchbaseException> decodingFailure()If the parser fails due to malformed input the cause is returned here. -
initialize
void initialize(com.couchbase.client.core.deps.io.netty.channel.ChannelConfig channelConfig)Begins a new parsing session.- Parameters:
channelConfig- the channel config used for backpressure auto-read.
-
cleanup
void cleanup()Releases resources managed by the parser and prepares it for reuse. -
feed
void feed(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf input)Parses the given JSON document fragment. The parser takes ownership of the buffer and is responsible for releasing it. -
endOfInput
void endOfInput()Indicates the complete JSON document has been fed to the parser. -
rows
Returns the currently assigned flux for the rows. -
trailer
Returns the currently assigned mono for the trailer bits. -
updateRequestContext
Sets the request context for the current request in the parser, can be used for error handling. -
updateResponseHeader
void updateResponseHeader(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse responseHeader)Sets the current response header if present.
-