Introduction to Streamstone
Streamstone is a lightweight library designed to make the creation of scalable event-sourced applications using Azure Table Storage simpler. The library leverages a straightforward, functional style API inspired by Greg Young's Event Store.
Key Features
Streamstone offers a variety of powerful features for developers:
- ACID Compliance: Streamstone ensures that all transactions are atomic, consistent, isolated, and durable, making it highly reliable for critical applications.
- Optimistic Concurrency: This feature allows multiple layers of concurrency, preventing conflicts and ensuring data integrity when multiple operations occur simultaneously.
- Duplicate Event Detection: Streamstone can effectively detect duplicate events using unique identifiers, maintaining data accuracy.
- Automatic Continuation: When carrying out operations that exceed the limitations of Azure Table Storage, Streamstone can seamlessly continue both write and read actions.
- Customizable Properties: Users can define and query custom properties for both streams and events.
- Inline Projections and Snapshots: These allow for the transformation and saving of data efficiently, with support for change tracking.
- Multi-Tenant and Sharding Friendly: With built-in support for multi-tenant architectures and sharding via jump consistent hashing, Streamstone is suitable for complex applications.
- Broad .NET Compatibility: The library is compatible with .NET Standard 2.0 and .NET Framework 4.6, accommodating a wide range of development environments.
Getting Started
Installation
To install Streamstone, simply run the following command in the NuGet Package Manager Console:
PM> Install-Package Streamstone
Building from Source
For those who wish to build Streamstone from source, it can be done on both Windows and Linux systems. Windows users need Visual Studio 2017 Update 3 or later and .NET Core SDK 2.0 or later. Linux users can utilize the dotnet build
command via the CLI tool.
Running Unit Tests
Streamstone allows you to run unit tests using Azurite, an npm package that emulates Azure Table Storage. Note that Azurite does not fully emulate Azure's functionality, which might lead to some test failures. Alternatively, real Azure testing can be conducted by setting the storage account connection string.
Design and Implementation
Streamstone functions as a delicate layer on top of Azure Table Storage, handling the low-level mechanics of event streams while the heavy lifting is managed by Azure. Its stateless, immutable API gives developers the freedom to choose their preferred payload serialization protocol. Key technical features include:
- Enforcing optimistic concurrency using stream headers for secure write operations.
- Managing duplicate events through unique RowKey identifiers in secondary indexes.
Use Cases and Applications
Streamstone offers various practical scenarios and examples:
- Stream Management: Provisioning, opening, writing to, and reading from streams are supported with easy-to-follow examples.
- Conflict and Duplicate Handling: The library includes guidelines for managing concurrency conflicts and duplicate events.
- Enhanced Functionality: Users can explore implementing stream directories, using snapshots, creating projections, and querying events.
Streamstone is also showcased in classic CQRS demos and for stateful applications, such as event-sourced actors in Project Orleans.
Limitations
Due to Azure Table Storage's constraints, developers must adhere to specific limitations, such as batch size and entity size restrictions, when using Streamstone. The library aids in managing these limitations by automatically flushing batches or throwing exceptions if thresholds are exceeded.
Community and Support
Streamstone is supported by an active community, providing a collaborative space for developers to discuss and enhance their usage of the library. It is released under the MIT License, encouraging open and flexible use.
Streamstone is a powerful tool for developers aiming to leverage Azure Table Storage for event-sourced applications, balancing simplicity and functionality to enhance productivity and application performance.