Bases: Exception

Error when encountering a name collision between event streams.


Bases: object

Internal representation of a stream of OrderedBuildEvents.

This class provides in-memory storage of the events in a given Build Event Stream. Many of these Build Event Streams may relate to the same build, or even to the same invocation of a tool.


stream_id (StreamId) – A gRPC message defining the ID of this stream.


Publish an OrderedBuildEvent into the stream.


event (OrderedBuildEvent) – The event to publish to the stream. This is an OrderedBuildEvent message from the publish_build_event proto.

query_events(query: Optional[str] = None)Iterator[]

Query the contents of this stream.

Filter the contents of the event stream by some query, returning an iterator of matching OrderedBuildEvents.


The filtering functionality of this method is currently not implemented, and the iterator returned contains all the events in the stream no matter what query is used.


query (str) – The filter string to use when querying events.


Convert this object to a BuildEventStream gRPC message.

This method converts this internal event stream representation into a QueryEventStreamsResponse.BuildEventStream gRPC message, as defined in the query_build_events proto.


Bases: object

In-memory storage of Build Event Streams.

This class stores a collection of Build Event Streams, and handles both creation of new streams and querying the streams which already exist based on their stream ID. Streams are stored in-memory and are lost on service restart, so shouldn’t be relied on as a source of persistent data when using this storage class.

This class is similar to the .*Instance classes used by other BuildGrid services, in that it is instantiated by the config parser and used by a .*Service class instantiated by the server class. Unlike the other instance classes however, this class doesn’t have an instance_name attribute due to the Build Events protos not having the concept of multiple instances.

register_instance_with_server(instance_name: str, server: Server)

Register this BuildEventStreamStorage with the BuildGrid server

This method doesn’t make a lot of sense here since this isn’t really an “instance” in the same sense as other services have in BuildGrid.

The Build Events protocol doesn’t have support for instance names, so this is the closest thing to an instance we have however. As such this method is implemented to avoid a special case in the config parsing.

The provided instance name is currently ignored.

  • instance_name (str) – The name of the instance this service is defined in. Currently ignored.

  • server (Server) – The BuildGrid server to register this storage backend with.


Create and return a new BuildEventStream with the given ID.

This method creates a new BuildEventStream with the given StreamId, and returns it. If a stream with that ID already exists in this BuildEventStreamStorage, then a DuplicateStreamError is raised.


stream_id (StreamId) – The gRPC StreamId message containing the ID of the stream to create.


Return a BuildEventStream with the given stream ID.

This method takes a stream ID, converts it to a stream key, and returns the stream with that key if one exists.

This method will create a new BuildEventStream if one with the given ID doesn’t exist.


stream_id (StreamId) – The StreamID message from an event to get the BuildEventStream for.


A BuildEventStream with the given ID, or None.

get_matching_streams(stream_key_regex: str)List[]

Return a list of event streams which match the given key pattern.

This method takes a regular expression as a string, and returns a list of BuildEventStream objects whose stream key (based on the events’ StreamId) matches the regex.


stream_key_regex (str) – A regular expression to use to find matching streams.


List of BuildEventStream objects which have a key matching the given regex.