forked from event-driven-io/Blumchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose shortcut for table validation when bootstrapping publisher
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
using Blumchen.Database; | ||
using Blumchen.Serialization; | ||
using Npgsql; | ||
|
||
namespace Blumchen.Publications; | ||
|
||
public record PublisherOptions(TableDescriptorBuilder.MessageTable TableDescriptor, IJsonTypeResolver JsonTypeResolver); | ||
|
||
public static class PublisherOptionsExtensions | ||
{ | ||
public static async Task<PublisherOptions> EnsureTable(this PublisherOptions publisherOptions, NpgsqlDataSource dataSource, CancellationToken ct) | ||
{ | ||
await dataSource.EnsureTableExists(publisherOptions.TableDescriptor, ct); | ||
return publisherOptions; | ||
} | ||
|
||
public static Task<PublisherOptions> EnsureTable(this PublisherOptions publisherOptions, | ||
string connectionString, CancellationToken ct) | ||
=> EnsureTable(publisherOptions, new NpgsqlDataSourceBuilder(connectionString).Build(), ct); | ||
} |