haydnv / tinychain

A next-gen database + SaaS framework for rapid development and integration of enterprise services
Apache License 2.0
46 stars 10 forks source link

implement support for an asyncronous event type, including publish & subscribe features #253

Open haydnv opened 9 months ago

haydnv commented 9 months ago

Example use cases:

haydnv commented 5 months ago

A stream is a queue of events and a list of subscribers. The contents of an event are a Tuple of Values. An event may have no content at all (e.g. an event type PageView may simply prompt the subscriber to increment a counter). An event differs from a request in that it is asynchronous–a requestor waits for the request to complete, but an event sender does not wait for the event to be delivered, only acknowledged by the stream which keeps track of subscribers.

Any service method may subscribe to an event stream. A “subscription” is an OpRef which is used to deliver events, which are then deleted after they have been delivered to all subscribers or after a configured maximum lifetime has elapsed. An event will be delivered to all subscribers as soon as it is received, i.e. the lead host of the transaction in which the event is received.

A stream may implement a background task by subscribing to itself. This is possible because a stream may not consume a self-published event within the same transaction in which the event was published.

Streams will be addressable under the /streams directory in userspace. In the future, live media may be available under the /media directory.