…
//
deadline = ResolveDeadlinePolicy(deadline);
var eventsArray = events.ToArrayEx();
IWriteResult result;
try
{
result = await _clients.Writer.AppendToStreamAsync(
streamName,
StreamState.StreamExists,
eventsArray
, deadline: deadline
, cancellationToken: cancellationToken
).ConfigureAwait(false);
}
catch (WrongExpectedVersionException)
{
await _clients.Writer.SetStreamMetadataAsync(
streamName,
StreamState.NoStream,
new StreamMetadata(1)
, deadline: deadline
, cancellationToken: cancellationToken
).ConfigureAwait(false);
//using the reader to write as the writer is not able to write. It hangs in the following
result = await _clients.Reader.AppendToStreamAsync(
streamName,
StreamState.NoStream,
eventsArray
, deadline: deadline
, cancellationToken: cancellationToken
).ConfigureAwait(false);
}
…