Package com.google.cloud.logging
Class LogEntryServerStream
- java.lang.Object
-
- com.google.cloud.logging.LogEntryServerStream
-
public class LogEntryServerStream extends Object implements Iterable<LogEntry>
The class implementsIterable
interface over {@see LogEntry}. It wraps aroundBidiStream
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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cleanly cancels a partially consumed stream.List<LogEntry>
convert(TailLogEntriesResponse resp)
com.google.api.gax.rpc.BidiStream<TailLogEntriesRequest,TailLogEntriesResponse>
getInternalStream()
boolean
isReceiveReady()
Returns true if the next call to the iterator's hasNext() or next() is guaranteed to be nonblocking.Iterator<LogEntry>
iterator()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getInternalStream
public com.google.api.gax.rpc.BidiStream<TailLogEntriesRequest,TailLogEntriesResponse> getInternalStream()
-
convert
public List<LogEntry> convert(TailLogEntriesResponse resp)
-
isReceiveReady
public boolean isReceiveReady()
Returns true if the next call to the iterator's hasNext() or next() is guaranteed to be nonblocking.- Returns:
- If the call on any of the iterator's methods is guaranteed to be nonblocking.
-
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.
-
-