Streams

sec.api.Streams
See theStreams companion object
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.

Attributes

Companion
object
Source
streams.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

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.

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.

Attributes

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.

Deletes a stream and returns DeleteResult with current log position after a successful operation. Failure to fulfill the expected state 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.

Attributes

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.

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

Attributes

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

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.

Attributes

Returns

a fs2.Stream that emits Event values.

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

Read events from an individual stream.

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.

Attributes

Returns

a fs2.Stream that emits Event values.

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

Subscribes to the global stream, StreamId.All.

Subscribes to the global stream, StreamId.All.

Value parameters

exclusiveFrom

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

resolveLinkTos

whether to resolve EventType.LinkTo events automatically.

Attributes

Returns

a fs2.Stream that emits Event values.

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

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 scala.None to subscribe from the beginning.

filterOptions

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

resolveLinkTos

whether to resolve EventType.LinkTo events automatically.

Attributes

Returns

a fs2.Stream that emits either sec.api.Checkpoint or Event values. How frequent sec.api.Checkpoint is emitted depends on filterOptions.

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

Subscribes to an individual stream.

Subscribes to an individual stream.

Value parameters

exclusiveFrom

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

resolveLinkTos

whether to resolve EventType.LinkTo events automatically.

streamId

the id of the stream to subscribe to.

Attributes

Returns

a fs2.Stream that emits Event 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.

Tombstones a stream and returns TombstoneResult with current log position after a successful operation. Failure to fulfill the expected state 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.

Attributes

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.

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.

Attributes

Source
streams.scala