Class GHNotificationStream

java.lang.Object
org.kohsuke.github.GHNotificationStream
All Implemented Interfaces:
Iterable<GHThread>

public class GHNotificationStream extends Object implements Iterable<GHThread>
Listens to GitHub notification stream.

This class supports two modes of retrieving notifications that can be controlled via nonBlocking(boolean).

In the blocking mode, which is the default, iterator will be infinite. The call to Iterator.next() will block until a new notification arrives. This is useful for application that runs perpetually and reacts to notifications.

In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub, then quit. This is useful for a batch application to process the current set of notifications.

Author:
Kohsuke Kawaguchi
See Also:
  • Method Details

    • read

      public GHNotificationStream read(boolean v)
      Should the stream include notifications that are already read?.
      Parameters:
      v - the v
      Returns:
      the gh notification stream
    • participating

      public GHNotificationStream participating(boolean v)
      Should the stream be restricted to notifications in which the user is directly participating or mentioned?.
      Parameters:
      v - the v
      Returns:
      the gh notification stream
    • since

      public GHNotificationStream since(long timestamp)
      Since gh notification stream.
      Parameters:
      timestamp - the timestamp
      Returns:
      the gh notification stream
    • since

      public GHNotificationStream since(Date dt)
      Since gh notification stream.
      Parameters:
      dt - the dt
      Returns:
      the gh notification stream
    • nonBlocking

      public GHNotificationStream nonBlocking(boolean v)
      If set to true, iterator() will stop iterating instead of blocking and waiting for the updates to arrive.
      Parameters:
      v - the v
      Returns:
      the gh notification stream
    • iterator

      public Iterator<GHThread> iterator()
      Returns an infinite blocking Iterator that returns GHThread as notifications arrive.
      Specified by:
      iterator in interface Iterable<GHThread>
      Returns:
      the iterator
    • markAsRead

      public void markAsRead() throws IOException
      Mark as read.
      Throws:
      IOException - the io exception
    • markAsRead

      public void markAsRead(long timestamp) throws IOException
      Marks all the notifications as read.
      Parameters:
      timestamp - the timestamp
      Throws:
      IOException - the io exception
    • getRoot

      @Deprecated public GitHub getRoot()
      Deprecated.
      For access to the GitHub instance, use a local copy instead of pulling it out of objects.
      Get the root GitHub instance for this object.
      Returns:
      the root GitHub instance