StreamStore.NoSql.Cassandra 0.12.0

dotnet add package StreamStore.NoSql.Cassandra --version 0.12.0
                    
NuGet\Install-Package StreamStore.NoSql.Cassandra -Version 0.12.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StreamStore.NoSql.Cassandra" Version="0.12.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StreamStore.NoSql.Cassandra" Version="0.12.0" />
                    
Directory.Packages.props
<PackageReference Include="StreamStore.NoSql.Cassandra" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StreamStore.NoSql.Cassandra --version 0.12.0
                    
#r "nuget: StreamStore.NoSql.Cassandra, 0.12.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=StreamStore.NoSql.Cassandra&version=0.12.0
                    
Install as a Cake Addin
#tool nuget:?package=StreamStore.NoSql.Cassandra&version=0.12.0
                    
Install as a Cake Tool

StreamStore.NoSql.Cassandra

NuGet version (StreamStore.NoSql.Cassandra)

Apache Cassandra and Azure Cosmos DB for Apache Cassandra storage for StreamStore asynchronous event sourcing library built on top of CassandraCSharpDriver.

Does not support event duplication detection based on event ID due to lack of unique constraints.

ACID compliance and considerations

Despite the fact that Apache Cassandra is not ACID compliant DBMS, library provides ACID guarantees for the operations that are performed within a single partition key - stream identifier.

Such guarantees are achieved by using following features:

Taking into account that configuration above significantly affects the performance of the system, and that not all scenarios requires ACID compliance, it has been decided to add possibility to change consistency levels via configuration.

Installation

To install the package, you can use the following command from the command line:

  dotnet add package StreamStore

  dotnet add package StreamStore.NoSql.Cassandra

or from Nuget Package Manager Console:


  Install-Package StreamStore

  Install-Package StreamStore.NoSql.Cassandra

Usage

Storage

By default the library provisioning schema automatically, however you must create keyspace or configure library to use already existing one.
By default the library uses streamstore keyspace in single tenant mode.
For multitenancy mode you must create keyspace per tenant in advance.

If you want to create table manually, you can use the following script:

CREATE TABLE IF NOT EXISTS events
    (id text,
    stream_id text,
    revision int,
    timestamp timestamp,
    data blob,
    custom_properties map<text,text>,
    PRIMARY KEY(stream_id, revision)
    );

Getting started

Since the library CassandraCSharpDriver as well as Apache Cassandra itself provides a lot of configuration options, it is not possible to cover all of them in the library configuration.
In this regards, decision has been made to provide ability to configure connectivity options via original API of CassandraCSharpDriver.

However, in case if you decided to use library with Azure Cosmos DB for Apache Cassandra, there is extension simplifies configuration by only connection string required.


  // Register single tenant implementation
      services.UseCassandra(x => {
          x.UseCosmosDb(connectionString);            // Optional. Required  if you want to use Azure Cosmos DB for Apache Cassandra
          x.ConfigureCluster(c =>                     // Required. Configure cluster options. Optional if you decided to use CosmosDB (see above).
              c.AddContactPoint("localhost"));        // Configure contact points.
         }
      )


  // Or enable multitenancy
  x.UseCassandraWithMultitenancy(
  // Configure storage options
   c => 
      c.UseCosmosDb(connectionString)              // Optional. Required  if you want to use Azure Cosmos DB for Apache Cassandra
       .Configureluster(x =>                        // Required. Configure cluster options. Optional if you decided to use CosmosDB (see above).
              x.AddContactPoint("localhost")),      // Configure contact points.

    // Configure multitenancy options
    x =>
      x.WithKeyspaceProvider<Provider>()                 // Required. Register your  ITenantKeyspaceProvider implementation.
       .UseTenantProvider<MyTenantProvider>();           // Optional. Register your ITenantProvider implementation.
  );

Full list of configuration options you can find in the Configuration options section.

Use in application code

How to use StreamStore in your application code you can find on StreamStore page.

Example

You can find an example of usage in the StreamStore.NoSql.Example project.
More information about how example application works you can find in StreamStore documentation.

Testing

In order to run tests placed in StreamStore.NoSql.Tests/Cassandra/Storage, you need to have a running Cassandra cluster. You can use docker-compose docker-compose.yaml to run it.

Configuration options

Below you can find the list of configuration options that can be used to configure the library.

// Register single tenant implementation 
    services.UseCassandra(x => 
         {
            x.UseCosmosDb(connectionString);                                    // Optional. Required  if you want to use Azure Cosmos DB for Apache Cassandra.
            x.UseCosmosDb(Configuration, connectionStringName);                 // You can also provide IConfiguration and connection string name to Cosmos DB, by default "StreamStore".
            x.ConfigureCluster(c =>                                             // Required. Configure cluster options. Optional if you decided to use CosmosDB (see above).
                    c.AddContactPoint("localhost"));                            // Configure contact points at least.
                                                                                // There is much more cluster options available.
            x.ConfigureStorage(c =>                                             // Optional. Configure storage options.
                    c.WithKeyspaceName("keyspacename")                          // Optional. Keyspace name. Default is streamstore.
                     .WithEventsTableName("tablename")                          // Optional. Table name. Default is events.
                     .WithReadConsistencyLevel(ConsistencyLevel.Quorum)         // Optional. Read consistency level. Default is All.
                     .WithWriteConsistencyLevel(ConsistencyLevel.Quorum)        // Optional. Write consistency level. Default is All.
                     .WithSerialConsistencyLevel(ConsistencyLevel.SerialLocal)  // Optional. Serial consistency level. Default is Serial.
            );
            x.WithSessionFactory<TFactory>()                                    // Optional. Register your ISessionFactory implementation.
          }
      );
  

  // Or enable multitenancy
  // More information about multitenancy configuration you can find in the StreamStore.
     services.UseCassandraWithMultitenancy(
        // Configure storage options, see above
        c => ...,
        // Configure multitenancy options
        x => 
         {
            x.WithKeyspaceProvider<Provider>();                                 // Required. Register your ITenantKeyspaceProvider implementation.
            x.WithTenantClusterConfigurator(c => ...);                          // Optional. Register delegate for configuring tenant cluster configuration based on default cluster.
            x.WithStorageConfigurationProvider<TProvider>();                    // Optional. Register your ITenantStorageConfigurationProvider implementation.
          }
      );

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.12.0 277 6/11/2025
0.11.0 279 6/11/2025
0.10.0 280 6/11/2025
0.9.0 88 5/31/2025
0.8.0 103 5/30/2025
0.7.0 132 5/29/2025
0.6.0 150 5/25/2025
0.5.0 94 4/5/2025
0.4.0 76 3/15/2025
0.3.0 120 11/29/2024
0.2.0 107 11/29/2024
0.1.0 113 11/26/2024