A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GreanTech/AtomEventStore/wiki/Writing-a-custom-storage-implementation below:

Writing a custom storage implementation · GreanTech/AtomEventStore Wiki · GitHub

AtomEventStore comes with a few built-in storage implementations, but you can also implement your own storage mechanism to take advantage of whichever technology you need to use. The only requirement is that the storage mechanism must enable you to read and write XML.

In order to implement a custom storage for AtomEventStore, you must implement the IAtomEventStorage interface, which only defines two methods:

public interface IAtomEventStorage
{
    XmlReader CreateFeedReaderFor(Uri href);

    XmlWriter CreateFeedWriterFor(AtomFeed atomFeed);
}

These methods are simply the read and write methods for the store.

When implementing the CreateFeedWriterFor method, the implementation is free to choose an appropriate naming or identification scheme that fits the underlying persistence technology. However, it must be able to find the written Atom feed when a client subsequently invokes CreateFeedReaderFor.

When the CreateFeedWriterFor method is invoked, the atomFeed argument contains at least a 'self' link (identified by IsSelfLink) identifying the Atom entry. The Href value of this link is the value used when CreateFeedReaderFor is subsequently invoked to read the Atom feed. In other words, this is the corrolation ID, so a naming or identification scheme must take this into account.

When implementing the CreateFeedReaderFor method, the implementation must attempt to return an XmlReader that corresponds to the href method argument. If no entry can be found, the method must return an XmlReader over an empty Atom feed.

One, relatively easy, way to create an XmlReader over an empty Atom feed is to invoke AtomEventStorage.CreateNewFeed(Uri).

The source code for AtomEventStore contains various implementations of IAtomEventStorage, including

These are fully functioning implementations, and not particularly complex, and since they are actual production code, they provide better examples than any toy example that could be provided here.

Although not required in order for AtomEventStore to work, implementations are also strongly encouraged to implement IEnumerable<UuidIri> if at all possible. This implementatation should enable clients to enumerate all event streams in a given storage implementation, which can sometimes be handy.

Again, the source code for AtomEventStore contains living examples of implementing IEnumerable<UuidIri>, e.g.

For example, in AtomEventsInFiles, the implementation will enumerate the IDs of all the event streams in the file system contained under the root directory.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4