StreamsDB

StreamsDB

  • Join
  • Chat
  • Docs

›Reference

Introduction

  • Introduction
  • Core Concepts

Gettings started

  • CLI
  • Go
  • .NET
  • Docker Compose

Reference

  • Connection String
  • .NET Driver API reference

Legal

  • Privacy policy
  • Beta Agreement
Edit

.NET Driver API reference

StreamsDB.Driver

Contents

  • ApiReflection
    • Descriptor
  • AppendStreamReply
    • FromFieldNumber
  • AppendStreamRequest
    • DatabaseFieldNumber
    • ExpectedVersionFieldNumber
    • MessagesFieldNumber
    • StreamFieldNumber
  • ConcurrencyCheck
    • ExpectStreamLastMessage(message)
    • ExpectStreamNotExists()
    • ExpectStreamVersion(version)
    • Skip()
  • CreateDatabaseRequest
    • NameFieldNumber
  • CreateUserRequest
    • PasswordFieldNumber
    • UsernameFieldNumber
  • DB
    • AppendStream(streamId,messages)
    • AppendStream(streamId,messages)
    • AppendStream(streamId,concurrencyCheck,messages)
    • AppendStream(streamId,concurrencyCheck,messages)
    • ReadLastMessageFromStream()
    • ReadMessageFromStream()
    • ReadStreamBackward(streamId,from,limit)
    • ReadStreamForward(streamId,from,limit)
    • SubscribeStream(streamId,from,cancellationToken)
  • DeleteMessageRequest
    • DatabaseFieldNumber
    • PositionFieldNumber
    • StreamFieldNumber
  • EnableAclRequest
    • PasswordFieldNumber
    • SignatureFieldNumber
    • UsernameFieldNumber
  • GetDatabaseReply
    • NameFieldNumber
  • GetDatabaseRequest
    • NameFieldNumber
  • GetDatabasesReply
    • DatabasesFieldNumber
  • GetStreamsReply
    • AfterCursorFieldNumber
    • BeforeCursorFieldNumber
    • CursorFieldNumber
    • DirectionFieldNumber
    • HasAfterFieldNumber
    • HasBeforeFieldNumber
    • ResultFieldNumber
    • TotalFieldNumber
  • GetStreamsRequest
    • CursorFieldNumber
    • DatabaseFieldNumber
    • DirectionFieldNumber
  • GrandUserToDatabaseRequest
    • DatabaseFieldNumber
    • UsernameFieldNumber
  • IStreamSlice
    • From
    • HasNext
    • Messages
    • Next
    • Reverse
    • Stream
  • IStreamSubscription
  • LoginReply
    • TokenFieldNumber
  • LoginRequest
    • PasswordFieldNumber
    • UsernameFieldNumber
  • Message
  • Message
    • HeaderFieldNumber
    • PositionFieldNumber
    • TimestampFieldNumber
    • TypeFieldNumber
    • ValueFieldNumber
    • Header
    • Position
    • Timestamp
    • Type
    • Value
  • MessageInput
  • MessageInput
    • HeaderFieldNumber
    • IdFieldNumber
    • TypeFieldNumber
    • ValueFieldNumber
    • Header
    • ID
    • Type
    • Value
  • NotFoundException
  • OperationAbortedException
  • ReadGlobalReply
    • DatabaseFieldNumber
    • FromFieldNumber
    • NextFieldNumber
    • ValuesFieldNumber
  • ReadGlobalRequest
    • DatabaseFieldNumber
    • FromFieldNumber
    • LimitFieldNumber
  • ReadStreamRequest
    • DatabaseFieldNumber
    • FromFieldNumber
    • LimitFieldNumber
    • ReverseFieldNumber
    • StreamFieldNumber
  • Slice
    • CountFieldNumber
    • FromFieldNumber
    • HasNextFieldNumber
    • HeadFieldNumber
    • MessagesFieldNumber
    • NextFieldNumber
    • ReverseFieldNumber
    • StreamFieldNumber
  • Streams
    • Descriptor
  • StreamsClient
    • #ctor(channel)
    • #ctor(callInvoker)
    • #ctor()
    • #ctor(configuration)
    • NewInstance()
  • StreamsDBClient
    • Connect(connectionString)
    • DB(db)
  • StreamsDBException
  • SubscribeStreamRequest
    • CountFieldNumber
    • DatabaseFieldNumber
    • FromFieldNumber
    • StreamFieldNumber

ApiReflection type

Namespace

StreamsDB.Driver.Wire

Summary

Holder for reflection information generated from Wire/api.proto

Descriptor property

Summary

File descriptor for Wire/api.proto

AppendStreamReply type

Namespace

StreamsDB.Driver.Wire

FromFieldNumber constants

Summary

Field number for the "from" field.

AppendStreamRequest type

Namespace

StreamsDB.Driver.Wire

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

ExpectedVersionFieldNumber constants

Summary

Field number for the "expectedVersion" field.

MessagesFieldNumber constants

Summary

Field number for the "messages" field.

StreamFieldNumber constants

Summary

Field number for the "stream" field.

ConcurrencyCheck type

Namespace

StreamsDB.Driver

Summary

ConcurrencyCheck specifies the optimistic concurrency check that needs to succeed before a write transaction gets committed. If the check reveals conflicting modifications, the write transaction is aborted.

Use Skip to disable the optimistic concurrency check, or use one of the other static methods of this class to specify a check.

Example

Here is an example that writes a strict monotonically increasing number to a stream. Because of the ExpectStreamLastMessage this example could be run concurrently and the numbers on the steam will still be monotonicly increasing:

int nextNumber;
ConcurrencyCheck check;
while (true) {
  // read the last message from the stream
  var (message, found) = await db.ReadMessageFromStream("exact-sequence", -1);
  if (found)
  {
    // get the number from the value of the last message and increase
    nextNumber = BitConverter.ToInt32(message.Value) + 1;
    // expect the message we read to be the last message on the stream
    check = ConcurrencyCheck.ExpectLastMessage(message);
  }
  else
  {
    nextNumber = 0;
    check = ConcurrencyCheck.ExpectVersion(0);
  }
  try {
    await db.AppendStream("exact-sequence", check, new MessageInput
    {
      Type = "int32",
      Value = BitConverter.GetBytes(nextNumber)
    });
  } catch(OperationAbortedException caught) {
    // The operation was aborted, typically due to
    // a concurrency issue such as a concurrency check failure.
    continue;
  }
}

ExpectStreamLastMessage(message) method

Summary

Expect the stream to have the version that is equal to the position of the specified messaage.

Returns

An optimistic concurrency control check that will only succeed if the stream version is equal to the position of the specified message.

Parameters
NameTypeDescription
messageStreamsDB.Driver.MessageThe message to use in the check.
Remarks

It's important to understand that only the position will be verfied, not the actual value of the message nor it's ID or headers.

ExpectStreamNotExists() method

Summary

ExpectStreamNotExists returns an optimistic concurrency check that will only succeed if the stream does not exist.

Returns

An optimistic concurrency control check that will only succeed if the stream does not exist.

Parameters

This method has no parameters.

ExpectStreamVersion(version) method

Summary

Expect the stream to have the specified version.

Returns

An optimistic concurrency control check that will only succeed if the stream has the specified version.

Parameters
NameTypeDescription
versionSystem.Int64The expected version of the stream.

Skip() method

Summary

Skip returns an optimistic concurrency check that will always succeed. In other words, the optimistic concurrency control will be disabled for the write transaction where this check is used.

Returns

An optimistic concurrency control check that will always succeed.

Parameters

This method has no parameters.

CreateDatabaseRequest type

Namespace

StreamsDB.Driver.Wire

NameFieldNumber constants

Summary

Field number for the "name" field.

CreateUserRequest type

Namespace

StreamsDB.Driver.Wire

PasswordFieldNumber constants

Summary

Field number for the "password" field.

UsernameFieldNumber constants

Summary

Field number for the "username" field.

DB type

Namespace

StreamsDB.Driver

Summary

DB represents a database in StreamsDB.

AppendStream(streamId,messages) method

Summary

AppendStream appends the provides messages to the specified stream.

Returns

The position in the stream of the first message that has been written.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to append to. If the stream does not exists, it will be created.
messagesSystem.Collections.Generic.IEnumerable{StreamsDB.Driver.MessageInput}The messages to append.

AppendStream(streamId,messages) method

Summary

AppendStream appends the provides messages to the specified stream.

Returns

The position in the stream of the first message that has been written.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to append to. If the stream does not exists, it will be created.
messagesStreamsDB.Driver.MessageInput[]The messages to append.

AppendStream(streamId,concurrencyCheck,messages) method

Summary

AppendStream appends the provides messages to the specified stream.

Returns

The position in the stream of the first message that has been written.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to append to. If the stream does not exists, it will be created.
concurrencyCheckStreamsDB.Driver.ConcurrencyCheckThe optimistic concurrency check. See ConcurrencyCheck for different options.
messagesStreamsDB.Driver.MessageInput[]The messages to append.

AppendStream(streamId,concurrencyCheck,messages) method

Summary

AppendStream appends the provides messages to the specified stream.

Returns

The position in the stream of the first message that has been written.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to append to. If the stream does not exists, it will be created.
concurrencyCheckStreamsDB.Driver.ConcurrencyCheckThe optimistic concurrency check. See ConcurrencyCheck for different options.
messagesSystem.Collections.Generic.IEnumerable{StreamsDB.Driver.MessageInput}The messages to append.

ReadLastMessageFromStream() method

Summary

ReadLastMessageFromStream returns the last message of a stream.

Returns

A tuple containing the message and a boolean indication whether the message was found or not.

Parameters

This method has no parameters.

ReadMessageFromStream() method

Summary

ReadMessageFromStream returns the message from the stream at the specified position.

Returns

A tuple containing the message and a boolean indication whether the message was found or not.

Parameters

This method has no parameters.

ReadStreamBackward(streamId,from,limit) method

Summary

ReadStreamBackward reads from a stream in the backward direction, in other words, reading from newer to older messages in the stream.

Returns

A stream slice.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to read from.
fromSystem.Int64The position to read from.
limitSystem.Int32The maximum number of messages to read.

ReadStreamForward(streamId,from,limit) method

Summary

ReadStreamForward reads from a stream in the forward direction, in other words, reading from older to newer messages in a stream.

Returns

A stream slice.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to read from.
fromSystem.Int64The position to read from.
limitSystem.Int32The maximum number of messages to read.

SubscribeStream(streamId,from,cancellationToken) method

Summary

SubscribeStream creates a stream subscription that allows you to read from a stream and receive future writes.

Returns

A stream subscription.

Parameters
NameTypeDescription
streamIdSystem.StringThe stream to subscribe to.
fromSystem.Int64The position to subscribe from.
cancellationTokenSystem.Threading.CancellationTokenThe cancellation token to cancel the subscription.

DeleteMessageRequest type

Namespace

StreamsDB.Driver.Wire

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

PositionFieldNumber constants

Summary

Field number for the "position" field.

StreamFieldNumber constants

Summary

Field number for the "stream" field.

EnableAclRequest type

Namespace

StreamsDB.Driver.Wire

PasswordFieldNumber constants

Summary

Field number for the "password" field.

SignatureFieldNumber constants

Summary

Field number for the "signature" field.

UsernameFieldNumber constants

Summary

Field number for the "username" field.

GetDatabaseReply type

Namespace

StreamsDB.Driver.Wire

NameFieldNumber constants

Summary

Field number for the "name" field.

GetDatabaseRequest type

Namespace

StreamsDB.Driver.Wire

NameFieldNumber constants

Summary

Field number for the "name" field.

GetDatabasesReply type

Namespace

StreamsDB.Driver.Wire

DatabasesFieldNumber constants

Summary

Field number for the "databases" field.

GetStreamsReply type

Namespace

StreamsDB.Driver.Wire

AfterCursorFieldNumber constants

Summary

Field number for the "afterCursor" field.

BeforeCursorFieldNumber constants

Summary

Field number for the "beforeCursor" field.

CursorFieldNumber constants

Summary

Field number for the "cursor" field.

DirectionFieldNumber constants

Summary

Field number for the "direction" field.

HasAfterFieldNumber constants

Summary

Field number for the "hasAfter" field.

HasBeforeFieldNumber constants

Summary

Field number for the "hasBefore" field.

ResultFieldNumber constants

Summary

Field number for the "result" field.

TotalFieldNumber constants

Summary

Field number for the "total" field.

GetStreamsRequest type

Namespace

StreamsDB.Driver.Wire

CursorFieldNumber constants

Summary

Field number for the "cursor" field.

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

DirectionFieldNumber constants

Summary

Field number for the "direction" field.

GrandUserToDatabaseRequest type

Namespace

StreamsDB.Driver.Wire

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

UsernameFieldNumber constants

Summary

Field number for the "username" field.

IStreamSlice type

Namespace

StreamsDB.Driver

Summary

Represents a slice of a stream that hold messages from a certain position in a stream.

From property

Summary

Gets the from position of this slice.

HasNext property

Summary

Gets an indication if there are more messages availble at the time of reading.

Messages property

Summary

Gets the messages.

Next property

Summary

Gets the next position to continue reading.

Reverse property

Summary

Gets an indication whether this slice is in reverse direction.

Stream property

Summary

Gets the name of the stream.

IStreamSubscription type

Namespace

StreamsDB.Driver

Summary

IStreamSubscription represents a subscription to a stream that can be used to get current and future messages from a stream.

LoginReply type

Namespace

StreamsDB.Driver.Wire

TokenFieldNumber constants

Summary

Field number for the "token" field.

LoginRequest type

Namespace

StreamsDB.Driver.Wire

PasswordFieldNumber constants

Summary

Field number for the "password" field.

UsernameFieldNumber constants

Summary

Field number for the "username" field.

Message type

Namespace

StreamsDB.Driver

Summary

Represents a message on a stream.

Message type

Namespace

StreamsDB.Driver.Wire

HeaderFieldNumber constants

Summary

Field number for the "header" field.

PositionFieldNumber constants

Summary

Field number for the "position" field.

TimestampFieldNumber constants

Summary

Field number for the "timestamp" field.

TypeFieldNumber constants

Summary

Field number for the "type" field.

ValueFieldNumber constants

Summary

Field number for the "value" field.

Header property

Summary

The header of this message in bytes.

Position property

Summary

The position of this message in the stream.

Timestamp property

Summary

The point in time this message was created.

Type property

Summary

The type of this message.

Value property

Summary

The value of this message in bytes.

MessageInput type

Namespace

StreamsDB.Driver

Summary

Represents a message that can be written to a stream.

MessageInput type

Namespace

StreamsDB.Driver.Wire

HeaderFieldNumber constants

Summary

Field number for the "header" field.

IdFieldNumber constants

Summary

Field number for the "id" field.

TypeFieldNumber constants

Summary

Field number for the "type" field.

ValueFieldNumber constants

Summary

Field number for the "value" field.

Header property

Summary

Gets or sets the header of the message.

ID property

Summary

Gets or sets the ID of the message.

Type property

Summary

Gets or sets the type of the message.

Value property

Summary

Gets or sets the value of the message.

NotFoundException type

Namespace

StreamsDB.Driver

Summary

Some requested entity (e.g., database, user or stream) was not found.

OperationAbortedException type

Namespace

StreamsDB.Driver

Summary

The operation was aborted, typically due to a concurrency issue such as a concurrency check failure.

ReadGlobalReply type

Namespace

StreamsDB.Driver.Wire

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

FromFieldNumber constants

Summary

Field number for the "from" field.

NextFieldNumber constants

Summary

Field number for the "next" field.

ValuesFieldNumber constants

Summary

Field number for the "values" field.

ReadGlobalRequest type

Namespace

StreamsDB.Driver.Wire

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

FromFieldNumber constants

Summary

Field number for the "from" field.

LimitFieldNumber constants

Summary

Field number for the "limit" field.

ReadStreamRequest type

Namespace

StreamsDB.Driver.Wire

Summary

The request message containing the user's name.

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

FromFieldNumber constants

Summary

Field number for the "from" field.

LimitFieldNumber constants

Summary

Field number for the "limit" field.

ReverseFieldNumber constants

Summary

Field number for the "reverse" field.

StreamFieldNumber constants

Summary

Field number for the "stream" field.

Slice type

Namespace

StreamsDB.Driver.Wire

CountFieldNumber constants

Summary

Field number for the "count" field.

FromFieldNumber constants

Summary

Field number for the "from" field.

HasNextFieldNumber constants

Summary

Field number for the "hasNext" field.

HeadFieldNumber constants

Summary

Field number for the "head" field.

MessagesFieldNumber constants

Summary

Field number for the "messages" field.

NextFieldNumber constants

Summary

Field number for the "next" field.

ReverseFieldNumber constants

Summary

Field number for the "reverse" field.

StreamFieldNumber constants

Summary

Field number for the "stream" field.

Streams type

Namespace

StreamsDB.Driver.Wire

Descriptor property

Summary

Service descriptor

StreamsClient type

Namespace

StreamsDB.Driver.Wire.Streams

Summary

Client for Streams

#ctor(channel) constructor

Summary

Creates a new client for Streams

Parameters
NameTypeDescription
channelGrpc.Core.ChannelThe channel to use to make remote calls.

#ctor(callInvoker) constructor

Summary

Creates a new client for Streams that uses a custom CallInvoker.

Parameters
NameTypeDescription
callInvokerGrpc.Core.CallInvokerThe callInvoker to use to make remote calls.

#ctor() constructor

Summary

Protected parameterless constructor to allow creation of test doubles.

Parameters

This constructor has no parameters.

#ctor(configuration) constructor

Summary

Protected constructor to allow creation of configured clients.

Parameters
NameTypeDescription
configurationGrpc.Core.ClientBase.ClientBaseConfigurationThe client configuration.

NewInstance() method

Summary

Creates a new instance of client from given ClientBaseConfiguration.

Parameters

This method has no parameters.

StreamsDBClient type

Namespace

StreamsDB.Driver

Summary

Represents a client connection to a StreamsDB server.

Connect(connectionString) method

Summary

Connect to a StreamsDB server.

Returns
Parameters
NameTypeDescription
connectionStringSystem.StringThe connection string that helps

DB(db) method

Summary

Get a handle to a database in StreamsDB.

Returns

A handle to the database.

Parameters
NameTypeDescription
dbSystem.StringThe name of the database, leave empty to use the name from the connection string of the StreamsDBClient.

StreamsDBException type

Namespace

StreamsDB.Driver

Summary

Base exception for all well known StreamsDB exceptions.

SubscribeStreamRequest type

Namespace

StreamsDB.Driver.Wire

CountFieldNumber constants

Summary

Field number for the "count" field.

DatabaseFieldNumber constants

Summary

Field number for the "database" field.

FromFieldNumber constants

Summary

Field number for the "from" field.

StreamFieldNumber constants

Summary

Field number for the "stream" field.

← Connection StringPrivacy policy →
  • Contents
  • ApiReflection type
    • Descriptor property
  • AppendStreamReply type
    • FromFieldNumber constants
  • AppendStreamRequest type
    • DatabaseFieldNumber constants
    • ExpectedVersionFieldNumber constants
    • MessagesFieldNumber constants
    • StreamFieldNumber constants
  • ConcurrencyCheck type
    • ExpectStreamLastMessage(message) method
    • ExpectStreamNotExists() method
    • ExpectStreamVersion(version) method
    • Skip() method
  • CreateDatabaseRequest type
    • NameFieldNumber constants
  • CreateUserRequest type
    • PasswordFieldNumber constants
    • UsernameFieldNumber constants
  • DB type
    • AppendStream(streamId,messages) method
    • AppendStream(streamId,messages) method
    • AppendStream(streamId,concurrencyCheck,messages) method
    • AppendStream(streamId,concurrencyCheck,messages) method
    • ReadLastMessageFromStream() method
    • ReadMessageFromStream() method
    • ReadStreamBackward(streamId,from,limit) method
    • ReadStreamForward(streamId,from,limit) method
    • SubscribeStream(streamId,from,cancellationToken) method
  • DeleteMessageRequest type
    • DatabaseFieldNumber constants
    • PositionFieldNumber constants
    • StreamFieldNumber constants
  • EnableAclRequest type
    • PasswordFieldNumber constants
    • SignatureFieldNumber constants
    • UsernameFieldNumber constants
  • GetDatabaseReply type
    • NameFieldNumber constants
  • GetDatabaseRequest type
    • NameFieldNumber constants
  • GetDatabasesReply type
    • DatabasesFieldNumber constants
  • GetStreamsReply type
    • AfterCursorFieldNumber constants
    • BeforeCursorFieldNumber constants
    • CursorFieldNumber constants
    • DirectionFieldNumber constants
    • HasAfterFieldNumber constants
    • HasBeforeFieldNumber constants
    • ResultFieldNumber constants
    • TotalFieldNumber constants
  • GetStreamsRequest type
    • CursorFieldNumber constants
    • DatabaseFieldNumber constants
    • DirectionFieldNumber constants
  • GrandUserToDatabaseRequest type
    • DatabaseFieldNumber constants
    • UsernameFieldNumber constants
  • IStreamSlice type
    • From property
    • HasNext property
    • Messages property
    • Next property
    • Reverse property
    • Stream property
  • IStreamSubscription type
  • LoginReply type
    • TokenFieldNumber constants
  • LoginRequest type
    • PasswordFieldNumber constants
    • UsernameFieldNumber constants
  • Message type
  • Message type
    • HeaderFieldNumber constants
    • PositionFieldNumber constants
    • TimestampFieldNumber constants
    • TypeFieldNumber constants
    • ValueFieldNumber constants
    • Header property
    • Position property
    • Timestamp property
    • Type property
    • Value property
  • MessageInput type
  • MessageInput type
    • HeaderFieldNumber constants
    • IdFieldNumber constants
    • TypeFieldNumber constants
    • ValueFieldNumber constants
    • Header property
    • ID property
    • Type property
    • Value property
  • NotFoundException type
  • OperationAbortedException type
  • ReadGlobalReply type
    • DatabaseFieldNumber constants
    • FromFieldNumber constants
    • NextFieldNumber constants
    • ValuesFieldNumber constants
  • ReadGlobalRequest type
    • DatabaseFieldNumber constants
    • FromFieldNumber constants
    • LimitFieldNumber constants
  • ReadStreamRequest type
    • DatabaseFieldNumber constants
    • FromFieldNumber constants
    • LimitFieldNumber constants
    • ReverseFieldNumber constants
    • StreamFieldNumber constants
  • Slice type
    • CountFieldNumber constants
    • FromFieldNumber constants
    • HasNextFieldNumber constants
    • HeadFieldNumber constants
    • MessagesFieldNumber constants
    • NextFieldNumber constants
    • ReverseFieldNumber constants
    • StreamFieldNumber constants
  • Streams type
    • Descriptor property
  • StreamsClient type
    • #ctor(channel) constructor
    • #ctor(callInvoker) constructor
    • #ctor() constructor
    • #ctor(configuration) constructor
    • NewInstance() method
  • StreamsDBClient type
    • Connect(connectionString) method
    • DB(db) method
  • StreamsDBException type
  • SubscribeStreamRequest type
    • CountFieldNumber constants
    • DatabaseFieldNumber constants
    • FromFieldNumber constants
    • StreamFieldNumber constants
StreamsDB
Docs
Getting StartedCore conceptsReference
Community
Stack OverflowProject ChatTwitter
Code
GitHub
Copyright © 2019 StreamsDB