Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensuring that the event storage is created before doing FetchStreamSta… #3209

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Marten/Events/QueryEventStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,26 +249,30 @@ public IMartenQueryable<IEvent> QueryAllRawEvents()

public StreamState? FetchStreamState(Guid streamId)
{
_tenant.Database.EnsureStorageExists(typeof(IEvent));
var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamId, _tenant.TenantId));
return _session.ExecuteHandler(handler);
}

public Task<StreamState?> FetchStreamStateAsync(Guid streamId, CancellationToken token = default)
public async Task<StreamState?> FetchStreamStateAsync(Guid streamId, CancellationToken token = default)
{
await _tenant.Database.EnsureStorageExistsAsync(typeof(StreamAction), token).ConfigureAwait(false);
var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamId, _tenant.TenantId));
return _session.ExecuteHandlerAsync(handler, token);
return await _session.ExecuteHandlerAsync(handler, token).ConfigureAwait(false);
}

public StreamState? FetchStreamState(string streamKey)
{
_tenant.Database.EnsureStorageExists(typeof(IEvent));
var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamKey, _tenant.TenantId));
return _session.ExecuteHandler(handler);
}

public Task<StreamState?> FetchStreamStateAsync(string streamKey, CancellationToken token = default)
public async Task<StreamState?> FetchStreamStateAsync(string streamKey, CancellationToken token = default)
{
await _tenant.Database.EnsureStorageExistsAsync(typeof(StreamAction), token).ConfigureAwait(false);
var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamKey, _tenant.TenantId));
return _session.ExecuteHandlerAsync(handler, token);
return await _session.ExecuteHandlerAsync(handler, token).ConfigureAwait(false);
}

private IEventStorage eventStorage()
Expand Down
Loading