Streams

trait Streams[F[_]]

API for interacting with streams in EventStoreDB.

==Main operations==

  • subscribing to the global stream or an individual stream.
  • reading from the global stream or an individual stream.
  • appending event data to an existing stream or creating a new stream.
  • deleting events from a stream.
Type parameters:
F

the effect type in which Streams operates.

Companion:
object
Source:
streams.scala
class Object
trait Matchable
class Any

Value members

Abstract methods

def appendToStream(streamId: StreamId, expectedState: StreamState, data: NonEmptyList[EventData]): F[WriteResult]

Appends EventData to a stream and returns WriteResult with current positions of the stream after a successful operation. Failure to fulfill the expected state is manifested by raising sec.api.exceptions.WrongExpectedState.

Appends EventData to a stream and returns WriteResult with current positions of the stream after a successful operation. Failure to fulfill the expected state is manifested by raising sec.api.exceptions.WrongExpectedState.

Value parameters:
data

event data to be appended to the stream. See EventData.

expectedState

the state that the stream is expected to in. See StreamState for details.

streamId

the id of the stream to append to.

See also:

https://ahjohannessen.github.io/sec/docs/writing for details about appending to a stream.

Source:
streams.scala
def delete(streamId: StreamId, expectedState: StreamState): F[DeleteResult]

Deletes a stream and returns DeleteResult with current log position after a successful operation. Failure to fulfill the expected stated is manifested by raising sec.api.exceptions.WrongExpectedState.

Deletes a stream and returns DeleteResult with current log position after a successful operation. Failure to fulfill the expected stated is manifested by raising sec.api.exceptions.WrongExpectedState.

Value parameters:
expectedState

the state that the stream is expected to in. See StreamState for details.

streamId

the id of the stream to delete.

See also:

https://ahjohannessen.github.io/sec/docs/deleting for details about what it means to delete a stream.

Note:

Deleted streams can be recreated.

Source:
streams.scala

Returns an sec.api.streams.Reads instance. This is useful when you need more granularity from readAll or readStream operations.

Returns an sec.api.streams.Reads instance. This is useful when you need more granularity from readAll or readStream operations.

Source:
streams.scala
def readAll(from: LogPosition, direction: Direction, maxCount: Long, resolveLinkTos: Boolean): Stream[F, AllEvent]

Read events from the global stream, sec.StreamId.All.

Read events from the global stream, sec.StreamId.All.

Value parameters:
direction

whether to read forwards or backwards.

from

log position to read from.

maxCount

limits maximum events returned.

resolveLinkTos

whether to resolve ")">EventType.LinkTo events automatically.

Returns:

a Stream that emits AllEvent values.

Source:
streams.scala
def readStream(streamId: StreamId, from: StreamPosition, direction: Direction, maxCount: Long, resolveLinkTos: Boolean): Stream[F, StreamEvent]

Read events from an individual stream. A sec.api.exceptions.StreamNotFound is raised when the stream does not exist.

Read events from an individual stream. A sec.api.exceptions.StreamNotFound is raised when the stream does not exist.

Value parameters:
direction

whether to read forwards or backwards.

from

stream position to read from.

maxCount

limits maximum events returned.

resolveLinkTos

whether to resolve ")">EventType.LinkTo events automatically.

streamId

the id of the stream to subscribe to.

Returns:

a Stream that emits StreamEvent values.

Source:
streams.scala
def subscribeToAll(exclusiveFrom: Option[LogPosition], resolveLinkTos: Boolean): Stream[F, AllEvent]

Subscribes to the global stream, StreamId.All.

Subscribes to the global stream, StreamId.All.

Value parameters:
exclusiveFrom

position to start from. Use None to subscribe from the beginning.

resolveLinkTos

whether to resolve ")">EventType.LinkTo events automatically.

Returns:

a Stream that emits AllEvent values.

Source:
streams.scala
def subscribeToAll(exclusiveFrom: Option[LogPosition], filterOptions: SubscriptionFilterOptions, resolveLinkTos: Boolean): Stream[F, Either[Checkpoint, AllEvent]]

Subscribes to the global stream, StreamId.All using a subscription filter.

Subscribes to the global stream, StreamId.All using a subscription filter.

Value parameters:
exclusiveFrom

log position to start from. Use None to subscribe from the beginning.

filterOptions

to use when subscribing - See sec.api.SubscriptionFilterOptions.

resolveLinkTos

whether to resolve ")">EventType.LinkTo events automatically.

Returns:

a Stream that emits either Checkpoint or AllEvent values. How frequent Checkpoint is emitted depends on filterOptions.

Source:
streams.scala
def subscribeToStream(streamId: StreamId, exclusiveFrom: Option[StreamPosition], resolveLinkTos: Boolean): Stream[F, StreamEvent]

Subscribes to an individual stream.

Subscribes to an individual stream.

Value parameters:
exclusiveFrom

stream position to start from. Use None to subscribe from the beginning.

resolveLinkTos

whether to resolve ")">EventType.LinkTo events automatically.

streamId

the id of the stream to subscribe to.

Returns:

a Stream that emits StreamEvent values.

Source:
streams.scala
def tombstone(streamId: StreamId, expectedState: StreamState): F[TombstoneResult]

Tombstones a stream and returns TombstoneResult with current log position after a successful operation. Failure to fulfill the expected stated is manifested by raising sec.api.exceptions.WrongExpectedState.

Tombstones a stream and returns TombstoneResult with current log position after a successful operation. Failure to fulfill the expected stated is manifested by raising sec.api.exceptions.WrongExpectedState.

Value parameters:
expectedState

the state that the stream is expected to in. See StreamState for details.

streamId

the id of the stream to delete.

See also:

https://ahjohannessen.github.io/sec/docs/deleting for details about what it means to tombstone a stream.

Note:

Tombstoned streams can never be recreated.

Source:
streams.scala

Returns an instance that uses provided UserCredentials. This is useful when an operation requires different credentials from what is provided through configuration.

Returns an instance that uses provided UserCredentials. This is useful when an operation requires different credentials from what is provided through configuration.

Value parameters:
creds

Custom user credentials to use.

Source:
streams.scala