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

Subscription docs #3161

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions docs/configuration/hostbuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public interface IConfigureMarten
void Configure(IServiceProvider services, StoreOptions options);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L894-L905' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L902-L913' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

You could alternatively implement a custom `IConfigureMarten` (or `IConfigureMarten<T> where T : IDocumentStore` if you're [working with multiple databases](#working-with-multiple-marten-databases)) class like so:
Expand Down Expand Up @@ -276,7 +276,7 @@ public interface IAsyncConfigureMarten
ValueTask Configure(StoreOptions options, CancellationToken cancellationToken);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L907-L919' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iasyncconfiguremarten' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L915-L927' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iasyncconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

As an example from the tests, here's a custom version that uses the Feature Management service:
Expand Down
574 changes: 572 additions & 2 deletions docs/events/subscriptions.md

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions src/CoreTests/Bugs/Bug_3145_migration_to_tenanted.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Marten;
using Marten.Schema;
using Marten.Storage;
using Marten.Testing.Harness;
using Npgsql;
using Shouldly;
using Weasel.Core;
using Weasel.Postgresql;
using Xunit;

namespace CoreTests.Bugs;

public class Bug_3145_migration_to_tenanted : BugIntegrationContext
{
[Fact]
public async Task can_retrofit_to_multitenanted_later()
{
var mapping = new DocumentMapping(typeof(TestDoc), new StoreOptions{DatabaseSchemaName = "bugs"});

var table = new DocumentTable(mapping);

using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString);
await conn.OpenAsync();
await table.CreateAsync(conn);

mapping.TenancyStyle = TenancyStyle.Conjoined;
var table2 = new DocumentTable(mapping);
var migration = await SchemaMigration.DetermineAsync(conn, table2);
await new PostgresqlMigrator().ApplyAllAsync(conn, migration, AutoCreate.CreateOrUpdate);

var delta = await table2.FindDeltaAsync(conn);

if (delta.Difference != SchemaPatchDifference.None)
{
var writer = new StringWriter();
delta.WriteUpdate(new PostgresqlMigrator(), writer);

throw new Exception("Found delta:\n" + writer.ToString());
}


}
}

public record TestDoc(Guid Id, string Column);
2 changes: 2 additions & 0 deletions src/DaemonTests/DaemonTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
Expand All @@ -17,6 +18,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.6.2"/>
<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EventSourcingTests\EventSourcingTests.csproj"/>
Expand Down
Loading
Loading