StreamStore.NoSql.Cassandra 0.1.0

dotnet add package StreamStore.NoSql.Cassandra --version 0.1.0                
NuGet\Install-Package StreamStore.NoSql.Cassandra -Version 0.1.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.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StreamStore.NoSql.Cassandra --version 0.1.0                
#r "nuget: StreamStore.NoSql.Cassandra, 0.1.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.
// Install StreamStore.NoSql.Cassandra as a Cake Addin
#addin nuget:?package=StreamStore.NoSql.Cassandra&version=0.1.0

// Install StreamStore.NoSql.Cassandra as a Cake Tool
#tool nuget:?package=StreamStore.NoSql.Cassandra&version=0.1.0                

StreamStore.NoSql.Cassandra

NuGet version (StreamStore.NoSql.Cassandra)

Apache Cassandra storage for StreamStore asynchronous event sourcing library built on top of CassandraCSharpDriver.

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,
    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.

services.ConfigureStreamStore(x =>...
  
  // Register single tenant implementation
  x.WithSingleDatabase(c => ...
      c.UseCassandra(x =>
          x.ConfigureCluster(c =>                    // Required. Configure cluster options.
              c.AddContactPoint("localhost"))        // Configure contact points.
      )
  )

  // Or enable multitenancy
  x.WithMultitenancy(c => ...
      c.UseTenantProvider<MyTenantProvider>()         // Optional. Register your  ITenantProvider implementation.
                                                      // Required if you want schema to be provisioned for each tenant.
      c.UseCassandra(x => 
          x.WithKeyspaceProvider<Provider>()          // Required. Register your  ITenantKeyspaceProvider implementation.
            ConfigureDefaultCluster(c =>              // Required. Configure cluster options.
                  c.AddContactPoint("localhost"))     // Configure contact points.
      
      )
  )
); 

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.

Testing

In order to run tests placed in StreamStore.NoSql.Tests/Cassandra/Database, 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
  x.WithSingleDatabase(c => ...
      c.UseCassandra(x => 
         {
            x.ConfigureCluster(x =>                                             // Required. Configure cluster options.
                    c.AddContactPoint("localhost"));                            // Configure contact points at least.
                                                                                // There is much more cluster options available.
            x.ConfigureStorage(x =>                                             // 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
  x.WithMultitenancy(c => ...
                                                                                // More information about multitenancy configuration you can find in the StreamStore.
     c.UseCassandra(x => 
         {
            x.WithKeyspaceProvider<Provider>();                                 // Required. Register your ITenantKeyspaceProvider implementation.

            x.ConfigureDefaultCluster(x =>                                      // Required. Configure default cluster options.
                    x.AddContactPoint("localhost"));                            // Configure contact points at least.
                                                                                // There is much more cluster options available.
            x.ConfigureStoragePrototype(c =>                                    // Optional. Configure storage options as prototype for tenant storage configuration.
                    c.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.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. 
.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.1.0 45 11/26/2024