Class LogEntryServerStream (3.8.0)

public class LogEntryServerStream implements Iterable<LogEntry>

The class implements {@Iterable } interface over {@see LogEntry}. It wraps around {@BidiStream } bi-directional gRPC stream to support iterating through ingested responses. The class uses {@see LogEntryIterator} to iterate through the processed responses. The stream should be explicitly canceled by calling {@see LogEntryServerStream#cancel()} method. The class does not provide recovery or resuming functionality over the stream.

To iterate run:


 LogEntryServerStream stream;
 // code to initialize stream
 for (LogEntry log : stream) {
   // do something with logs
 }
 stream.cancel();
 

The iteration can be blocked on waiting for another response sent in the stream.

Inheritance

java.lang.Object > LogEntryServerStream

Implements

Iterable<LogEntry>

Methods

cancel()

public void cancel()

Cleanly cancels a partially consumed stream. The associated iterator will return false for the hasNext() in the next iteration. This maintains the contract that an observed true from hasNext() will yield an item in next(), but afterwards will return false.

convert(TailLogEntriesResponse resp)

public List<LogEntry> convert(TailLogEntriesResponse resp)
Parameter
NameDescription
respTailLogEntriesResponse
Returns
TypeDescription
List<LogEntry>

getInternalStream()

public BidiStream<TailLogEntriesRequest,TailLogEntriesResponse> getInternalStream()
Returns
TypeDescription
BidiStream<TailLogEntriesRequest,TailLogEntriesResponse>

isReceiveReady()

public boolean isReceiveReady()

Returns true if the next call to the iterator's hasNext() or next() is guaranteed to be nonblocking.

Returns
TypeDescription
boolean

If the call on any of the iterator's methods is guaranteed to be nonblocking.

iterator()

public Iterator<LogEntry> iterator()
Returns
TypeDescription
Iterator<LogEntry>