Gitlab.Stream
The Stream
module provides an abstraction to GitLab's paginated endpoints. Stream creation does not initiate any network activity. When requests are made, results are buffered internally. Streams are not mutable.
'a parse
is the type of functions which extract elements from a paginated response.
next s
is the next element of the stream and a stream continuation if one exists. The input stream is not modified. This function offers an efficient, lazy, and uniform means to iterate over ordered API results which may be too numerous to fit into a single request/response pair.
map f s
is the lazy stream of f
applied to elements of s
as they are demanded.
take n s
is the lazy stream of the first n
elements of s
as they are demanded.
fold f a s
is the left fold of f
over the elements of s
with a base value of a
. Warning: this function may result in many successive API transactions.
find p s
is the first value in s
satisfying p
if one exists and a stream continuation for further ingestion.
iter f s
is activated after the application of f
to each element of s
.
to_list s
is a list with each element of s
. Warning: this function may result in many successive API transactions.
val of_list : 'a list -> 'a t
of_list l
is a stream with each element of l
. Occasionally, it is useful to write interfaces which operate generically on streams. of_list
allows you to use list values with those interfaces.
poll stream
is a stream with items newer than stream
's items and will not resolve until any timeouts indicated by GitLab have elapsed. By default, GitLab throttles polling requests to once per minute per URL endpoint.
val since : 'a t -> Endpoint.Version.t -> 'a t
since stream version
is stream
with version
but without any other change, i.e. the stream is not reset to its beginning. Used in conjunction with poll
, since
enables low-cost conditional re-synchronization of local state with GitLab state.
val version : 'a t -> Endpoint.Version.t option
version stream
is the version of stream
if one is known. After any stream element is forced, the stream version will be available unless GitLab violates its API specification.