.NET Driver API reference
StreamsDB.Driver
Contents
- ApiReflection
- AppendStreamReply
- AppendStreamRequest
- ConcurrencyCheck
- CreateDatabaseRequest
- CreateUserRequest
- 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
- EnableAclRequest
- GetDatabaseReply
- GetDatabaseRequest
- GetDatabasesReply
- GetStreamsReply
- GetStreamsRequest
- GrandUserToDatabaseRequest
- IStreamSlice
- IStreamSubscription
- LoginReply
- LoginRequest
- Message
- Message
- MessageInput
- MessageInput
- NotFoundException
- OperationAbortedException
- ReadGlobalReply
- ReadGlobalRequest
- ReadStreamRequest
- Slice
- Streams
- StreamsClient
- StreamsDBClient
- StreamsDBException
- SubscribeStreamRequest
type
ApiReflection Namespace
StreamsDB.Driver.Wire
Summary
Holder for reflection information generated from Wire/api.proto
property
Descriptor Summary
File descriptor for Wire/api.proto
type
AppendStreamReply Namespace
StreamsDB.Driver.Wire
constants
FromFieldNumber Summary
Field number for the "from" field.
type
AppendStreamRequest Namespace
StreamsDB.Driver.Wire
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
ExpectedVersionFieldNumber Summary
Field number for the "expectedVersion" field.
constants
MessagesFieldNumber Summary
Field number for the "messages" field.
constants
StreamFieldNumber Summary
Field number for the "stream" field.
type
ConcurrencyCheck 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;
}
}
method
ExpectStreamLastMessage(message) 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
Name | Type | Description |
---|---|---|
message | StreamsDB.Driver.Message | The 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.
method
ExpectStreamNotExists() 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.
method
ExpectStreamVersion(version) 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
Name | Type | Description |
---|---|---|
version | System.Int64 | The expected version of the stream. |
method
Skip() 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.
type
CreateDatabaseRequest Namespace
StreamsDB.Driver.Wire
constants
NameFieldNumber Summary
Field number for the "name" field.
type
CreateUserRequest Namespace
StreamsDB.Driver.Wire
constants
PasswordFieldNumber Summary
Field number for the "password" field.
constants
UsernameFieldNumber Summary
Field number for the "username" field.
type
DB Namespace
StreamsDB.Driver
Summary
DB represents a database in StreamsDB.
method
AppendStream(streamId,messages) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to append to. If the stream does not exists, it will be created. |
messages | System.Collections.Generic.IEnumerable{StreamsDB.Driver.MessageInput} | The messages to append. |
method
AppendStream(streamId,messages) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to append to. If the stream does not exists, it will be created. |
messages | StreamsDB.Driver.MessageInput[] | The messages to append. |
method
AppendStream(streamId,concurrencyCheck,messages) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to append to. If the stream does not exists, it will be created. |
concurrencyCheck | StreamsDB.Driver.ConcurrencyCheck | The optimistic concurrency check. See ConcurrencyCheck for different options. |
messages | StreamsDB.Driver.MessageInput[] | The messages to append. |
method
AppendStream(streamId,concurrencyCheck,messages) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to append to. If the stream does not exists, it will be created. |
concurrencyCheck | StreamsDB.Driver.ConcurrencyCheck | The optimistic concurrency check. See ConcurrencyCheck for different options. |
messages | System.Collections.Generic.IEnumerable{StreamsDB.Driver.MessageInput} | The messages to append. |
method
ReadLastMessageFromStream() 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.
method
ReadMessageFromStream() 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.
method
ReadStreamBackward(streamId,from,limit) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to read from. |
from | System.Int64 | The position to read from. |
limit | System.Int32 | The maximum number of messages to read. |
method
ReadStreamForward(streamId,from,limit) 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
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to read from. |
from | System.Int64 | The position to read from. |
limit | System.Int32 | The maximum number of messages to read. |
method
SubscribeStream(streamId,from,cancellationToken) Summary
SubscribeStream creates a stream subscription that allows you to read from a stream and receive future writes.
Returns
A stream subscription.
Parameters
Name | Type | Description |
---|---|---|
streamId | System.String | The stream to subscribe to. |
from | System.Int64 | The position to subscribe from. |
cancellationToken | System.Threading.CancellationToken | The cancellation token to cancel the subscription. |
type
DeleteMessageRequest Namespace
StreamsDB.Driver.Wire
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
PositionFieldNumber Summary
Field number for the "position" field.
constants
StreamFieldNumber Summary
Field number for the "stream" field.
type
EnableAclRequest Namespace
StreamsDB.Driver.Wire
constants
PasswordFieldNumber Summary
Field number for the "password" field.
constants
SignatureFieldNumber Summary
Field number for the "signature" field.
constants
UsernameFieldNumber Summary
Field number for the "username" field.
type
GetDatabaseReply Namespace
StreamsDB.Driver.Wire
constants
NameFieldNumber Summary
Field number for the "name" field.
type
GetDatabaseRequest Namespace
StreamsDB.Driver.Wire
constants
NameFieldNumber Summary
Field number for the "name" field.
type
GetDatabasesReply Namespace
StreamsDB.Driver.Wire
constants
DatabasesFieldNumber Summary
Field number for the "databases" field.
type
GetStreamsReply Namespace
StreamsDB.Driver.Wire
constants
AfterCursorFieldNumber Summary
Field number for the "afterCursor" field.
constants
BeforeCursorFieldNumber Summary
Field number for the "beforeCursor" field.
constants
CursorFieldNumber Summary
Field number for the "cursor" field.
constants
DirectionFieldNumber Summary
Field number for the "direction" field.
constants
HasAfterFieldNumber Summary
Field number for the "hasAfter" field.
constants
HasBeforeFieldNumber Summary
Field number for the "hasBefore" field.
constants
ResultFieldNumber Summary
Field number for the "result" field.
constants
TotalFieldNumber Summary
Field number for the "total" field.
type
GetStreamsRequest Namespace
StreamsDB.Driver.Wire
constants
CursorFieldNumber Summary
Field number for the "cursor" field.
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
DirectionFieldNumber Summary
Field number for the "direction" field.
type
GrandUserToDatabaseRequest Namespace
StreamsDB.Driver.Wire
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
UsernameFieldNumber Summary
Field number for the "username" field.
type
IStreamSlice Namespace
StreamsDB.Driver
Summary
Represents a slice of a stream that hold messages from a certain position in a stream.
property
From Summary
Gets the from position of this slice.
property
HasNext Summary
Gets an indication if there are more messages availble at the time of reading.
property
Messages Summary
Gets the messages.
property
Next Summary
Gets the next position to continue reading.
property
Reverse Summary
Gets an indication whether this slice is in reverse direction.
property
Stream Summary
Gets the name of the stream.
type
IStreamSubscription Namespace
StreamsDB.Driver
Summary
IStreamSubscription represents a subscription to a stream that can be used to get current and future messages from a stream.
type
LoginReply Namespace
StreamsDB.Driver.Wire
constants
TokenFieldNumber Summary
Field number for the "token" field.
type
LoginRequest Namespace
StreamsDB.Driver.Wire
constants
PasswordFieldNumber Summary
Field number for the "password" field.
constants
UsernameFieldNumber Summary
Field number for the "username" field.
type
Message Namespace
StreamsDB.Driver
Summary
Represents a message on a stream.
type
Message Namespace
StreamsDB.Driver.Wire
constants
HeaderFieldNumber Summary
Field number for the "header" field.
constants
PositionFieldNumber Summary
Field number for the "position" field.
constants
TimestampFieldNumber Summary
Field number for the "timestamp" field.
constants
TypeFieldNumber Summary
Field number for the "type" field.
constants
ValueFieldNumber Summary
Field number for the "value" field.
property
Header Summary
The header of this message in bytes.
property
Position Summary
The position of this message in the stream.
property
Timestamp Summary
The point in time this message was created.
property
Type Summary
The type of this message.
property
Value Summary
The value of this message in bytes.
type
MessageInput Namespace
StreamsDB.Driver
Summary
Represents a message that can be written to a stream.
type
MessageInput Namespace
StreamsDB.Driver.Wire
constants
HeaderFieldNumber Summary
Field number for the "header" field.
constants
IdFieldNumber Summary
Field number for the "id" field.
constants
TypeFieldNumber Summary
Field number for the "type" field.
constants
ValueFieldNumber Summary
Field number for the "value" field.
property
Header Summary
Gets or sets the header of the message.
property
ID Summary
Gets or sets the ID of the message.
property
Type Summary
Gets or sets the type of the message.
property
Value Summary
Gets or sets the value of the message.
type
NotFoundException Namespace
StreamsDB.Driver
Summary
Some requested entity (e.g., database, user or stream) was not found.
type
OperationAbortedException Namespace
StreamsDB.Driver
Summary
The operation was aborted, typically due to a concurrency issue such as a concurrency check failure.
type
ReadGlobalReply Namespace
StreamsDB.Driver.Wire
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
FromFieldNumber Summary
Field number for the "from" field.
constants
NextFieldNumber Summary
Field number for the "next" field.
constants
ValuesFieldNumber Summary
Field number for the "values" field.
type
ReadGlobalRequest Namespace
StreamsDB.Driver.Wire
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
FromFieldNumber Summary
Field number for the "from" field.
constants
LimitFieldNumber Summary
Field number for the "limit" field.
type
ReadStreamRequest Namespace
StreamsDB.Driver.Wire
Summary
The request message containing the user's name.
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
FromFieldNumber Summary
Field number for the "from" field.
constants
LimitFieldNumber Summary
Field number for the "limit" field.
constants
ReverseFieldNumber Summary
Field number for the "reverse" field.
constants
StreamFieldNumber Summary
Field number for the "stream" field.
type
Slice Namespace
StreamsDB.Driver.Wire
constants
CountFieldNumber Summary
Field number for the "count" field.
constants
FromFieldNumber Summary
Field number for the "from" field.
constants
HasNextFieldNumber Summary
Field number for the "hasNext" field.
constants
HeadFieldNumber Summary
Field number for the "head" field.
constants
MessagesFieldNumber Summary
Field number for the "messages" field.
constants
NextFieldNumber Summary
Field number for the "next" field.
constants
ReverseFieldNumber Summary
Field number for the "reverse" field.
constants
StreamFieldNumber Summary
Field number for the "stream" field.
type
Streams Namespace
StreamsDB.Driver.Wire
property
Descriptor Summary
Service descriptor
type
StreamsClient Namespace
StreamsDB.Driver.Wire.Streams
Summary
Client for Streams
constructor
#ctor(channel) Summary
Creates a new client for Streams
Parameters
Name | Type | Description |
---|---|---|
channel | Grpc.Core.Channel | The channel to use to make remote calls. |
constructor
#ctor(callInvoker) Summary
Creates a new client for Streams that uses a custom CallInvoker
.
Parameters
Name | Type | Description |
---|---|---|
callInvoker | Grpc.Core.CallInvoker | The callInvoker to use to make remote calls. |
constructor
#ctor() Summary
Protected parameterless constructor to allow creation of test doubles.
Parameters
This constructor has no parameters.
constructor
#ctor(configuration) Summary
Protected constructor to allow creation of configured clients.
Parameters
Name | Type | Description |
---|---|---|
configuration | Grpc.Core.ClientBase.ClientBaseConfiguration | The client configuration. |
method
NewInstance() Summary
Creates a new instance of client from given ClientBaseConfiguration
.
Parameters
This method has no parameters.
type
StreamsDBClient Namespace
StreamsDB.Driver
Summary
Represents a client connection to a StreamsDB server.
method
Connect(connectionString) Summary
Connect to a StreamsDB server.
Returns
Parameters
Name | Type | Description |
---|---|---|
connectionString | System.String | The connection string that helps |
method
DB(db) Summary
Get a handle to a database in StreamsDB.
Returns
A handle to the database.
Parameters
Name | Type | Description |
---|---|---|
db | System.String | The name of the database, leave empty to use the name from the connection string of the StreamsDBClient. |
type
StreamsDBException Namespace
StreamsDB.Driver
Summary
Base exception for all well known StreamsDB exceptions.
type
SubscribeStreamRequest Namespace
StreamsDB.Driver.Wire
constants
CountFieldNumber Summary
Field number for the "count" field.
constants
DatabaseFieldNumber Summary
Field number for the "database" field.
constants
FromFieldNumber Summary
Field number for the "from" field.
constants
StreamFieldNumber Summary
Field number for the "stream" field.