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§

  • A connection to a cache repo.
  • 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.
  • An event in a stream. This is slimmer than the EventRecord type, and is used for most public interactions with events.
  • A connection to an event repo. Event connections are meant to represent long running or repeated access to a log of events. They keep track of the last event they read and will only read events that have occurred since that event. This allows them to be used in a streaming context, where they can be run in the background or polled for new events.
  • A record of an event. This is designed to represent events in a log, and so it has more fields than a CacheRecord.
  • A connection to an intrepid repository that combines the functionality of a cache and an event connection.

Enums§

  • 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.
  • An error that can occur when interacting with a cache repository.
  • 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.
  • Errors that can occur when interacting with an event repository.

Traits§

  • The trait for a cache repository. Implement this trait to provide a cache repository interface for any given cache implementation.
  • The trait for an event repository. Implement this trait to provide an event repository interface for any given event storage implementation.
  • An intrepid repository combines the functionality of a cache and an event repo, and is automatically implemented for any type that implements both.
  • 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.
  • A trait for types that can be converted into an event. Any given type that implements this trait can be published as an event.

Type Aliases§