Class RepoSequence


  • public class RepoSequence
    extends Object
    Class for managing an incrementing sequence backed by a git repository.

    The current sequence number is stored as UTF-8 text in a blob pointed to by a ref in the refs/sequences/* namespace. Multiple processes can share the same sequence by incrementing the counter using normal git ref updates. To amortize the cost of these ref updates, processes can increment the counter by a larger number and hand out numbers from that range in memory until they run out. This means concurrent processes will hand out somewhat non-monotonic numbers.

    • Method Detail

      • next

        public int next()
        Retrieves the next available sequence number.

        This method is thread-safe.

        Returns:
        the next available sequence number
      • next

        public com.google.common.collect.ImmutableList<Integer> next​(int count)
        Retrieves the next N available sequence number.

        This method is thread-safe.

        Parameters:
        count - the number of sequence numbers which should be returned
        Returns:
        the next N available sequence numbers
      • storeNew

        public static org.eclipse.jgit.transport.ReceiveCommand storeNew​(org.eclipse.jgit.lib.ObjectInserter ins,
                                                                         String name,
                                                                         int val)
                                                                  throws IOException
        Throws:
        IOException