StreamState

sealed trait StreamState

The expected state that a stream is currently in. There are four variants:

122Use Cases122

When you write to a stream for the first time you provide StreamState.NoStream. In order to decide if StreamState.NoStream is required you can try to read from the stream and if the read operation raises sec.api.exceptions.StreamNotFound you know that your expectation should be StreamState.NoStream.

When you do not have any expectation of the current state of a stream you should use StreamState.Any. This is, for instance, used when you just wish to append data to a stream regardless of other concurrent operations to the stream.

When you require that a stream, or its metadata stream, is present you should use StreamState.StreamExists.

When you need to implement optimistic concurrency you use StreamPosition.Exact and StreamState.NoStream as your exected stream state. You use StreamState.NoStream as expected stream state when you append to a stream for the first time, otherwise you use an StreamPosition.Exact value. A sec.api.exceptions.WrongExpectedState exception is rasised when the stream exists and has changed in the meantime.

Companion
object
class Object
trait Matchable
class Any
class Exact
object NoStream
object Any