Crate intrepid_model

Source
Expand description

§Intrepid Model

Intrepid is a magic handler kit where most of the boilerplate work is already done. For cases where you’d like to get the ergonomics of Bevy or Actix-Web, but for your own stuff.

Intrepid model establishes some basic plumbing for intrepid systems that lets implementers use intrepid in immediately useful ways.

  1. Cache, which is a key/value abstraction that lets intrepid functions easily save and access stored value.
  2. [Events], which is a message distribution abastraction that lets intrepid functions create and work over event streams, even persisted logs.

Together, these are enough to build out a lot of prototypical systems, using a “messages & memos” approach, where dozens of different kinds of typesafe messages and typesafe data structures can be orchestrated in a single serializable JSON-backed metaphor.

Structs§

CacheConnection
A connection to a cache repo.
CacheRecord
A record in a cache. This is designed to represent values in a simple key-value store, and so it has minimal fields. The uri field is the key, and the data field is the value. An extra meta field is included for additional information that may be useful, like timestamps or other bits that might not make sense to store in the data field.
Event
An event in a stream. This is slimmer than the EventRecord type, and is used for most public interactions with events.
EventRecord
A record of an event. This is designed to represent events in a log, and so it has more fields than a CacheRecord.
Subscription
A subscription to a stream of events. Subscriptions read events from a target stream and manage a tracking stream to measure their progress. Subscriptions generate their own ids when they are created, meaning every subscription is unique and replays the target stream from the beginning. In order to avoid replaying the target stream, use the Subscription::resume method and give it the id of an existing subscription.
SubscriptionCollection
A collection of subscriptions to streams of events.
SubscriptionConfig
A configuration for a subscription to a stream of events.
SubscriptionMarker
A marker struct to track subscription read progress.
SubscriptionName
Subscription names are used to identify streams that subscriptions read from. They are URI shaped, and must be valid URI strings.
SubscriptionStream
A handle to a subscription process. Creating a subscription handle will start a background process that will read events from the target stream, and send those events to the handle’s inbox for foreground processing.
SubscriptionWorker
A backgrounded subscription. This process works like an “actor”, as described in this blog post. It does the work to read from the event log and send any new events to a [subscription handle][super::SubscriptionHandle]. Usually, subscription processes aren’t interacted with directly, but are created by [Subscriber::background][super::Subscriber::background].
SubscriptionWorkerMap
A map of subscription processes which can be run as a stream.

Enums§

Cache
When dealing with caches, fetch values are the most common operation. This enum represents the result of a fetch operation, and can be used to determine if you’ve got a cache miss or not. It works a lot like the Option enum, but with a bit more context.
CacheRepoError
An error that can occur when interacting with a cache repository.
EventKind
The kind of an event. This is used to differentiate between the events in an event stream log. Entry events are the most common, and represent an event that has occurred. Marker events are used to indicate a point in a log which is significant for the system, but not for consumers.
EventRepoError
Errors that can occur when interacting with an event repository.

Traits§

CacheRepo
The trait for a cache repository. Implement this trait to provide a cache repository interface for any given cache implementation.
EventRepo
The trait for an event repository. Implement this trait to provide an event repository interface for any given event storage implementation.
IntoCache
A trait for types that can be converted into a cache record. Any given type that implements this trait can be inserted into a cache.
IntoEvent
A trait for types that can be converted into an event. Any given type that implements this trait can be published as an event.
IntrepidRepo
An intrepid repository combines the functionality of a cache and an event repo, and is automatically implemented for any type that implements both.
SubscriptionTopic
Implement this trait for a type that can be used as a subscription topic. That means that the type can be used to create a subscription to a stream of events using the Subscription type.

Type Aliases§

EventLog
Convenience type for a vec of event records
PendingEvents
Convenience type for a vec of events