.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
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
| 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.
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
| Name | Type | Description |
|---|---|---|
| version | System.Int64 | The 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
| 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. |
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
| 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. |
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
| 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. |
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
| 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. |
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
| 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. |
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
| 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. |
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
| 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. |
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
| Name | Type | Description |
|---|---|---|
| channel | Grpc.Core.Channel | The channel to use to make remote calls. |
#ctor(callInvoker) constructor
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. |
#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
| Name | Type | Description |
|---|---|---|
| configuration | Grpc.Core.ClientBase.ClientBaseConfiguration | The 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
| Name | Type | Description |
|---|---|---|
| connectionString | System.String | The connection string that helps |
DB(db) method
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. |
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.