Skip to content
Open
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
69 changes: 69 additions & 0 deletions Totem.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Timeline.IntegrationT
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.App.Tests", "src\Totem.App.Tests\Totem.App.Tests.csproj", "{AD26407A-1944-4507-A296-56338B4AF0EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Timeline.StreamsDb", "src\Totem.Timeline.StreamsDb\Totem.Timeline.StreamsDb.csproj", "{29CF069B-FEA0-46F7-92BD-50F5DBF0F8EB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{1E83E25F-0817-44AC-9432-C259839E1028}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Financial", "sample\Totem.Financial\Totem.Financial.csproj", "{B91407BE-E86E-41E0-855B-130B253C1F57}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Financial.Api", "sample\Totem.Financial.Api\Totem.Financial.Api.csproj", "{69B2C5B9-1E0A-482E-93EA-ED21A76B4637}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Financial.Service", "sample\Totem.Financial.Service\Totem.Financial.Service.csproj", "{0DDA6F82-A578-4B88-8526-0BBECD242DFD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.ImportProcess", "sample\Totem.ImportProcess\Totem.ImportProcess.csproj", "{6B5E7976-7C2E-48AB-9024-42568293D77A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.ImportProcess.Api", "sample\Totem.ImportProcess.Api\Totem.ImportProcess.Api.csproj", "{CB833795-0369-47F9-B3C5-599913EDF40D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.ImportProcess.Service", "sample\Totem.ImportProcess.Service\Totem.ImportProcess.Service.csproj", "{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.Financial.Integration", "sample\Totem.Financial.Integration\Totem.Financial.Integration.csproj", "{D4F525BB-2B19-484D-B78C-8840B527C64F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.EventBus", "src\Totem.EventBus\Totem.EventBus.csproj", "{6195C8D9-5A94-4ECB-A3E2-85F230153724}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totem.EventBus.StreamsDb", "src\Totem.EventBus.StreamsDb\Totem.EventBus.StreamsDb.csproj", "{666E075A-F8DD-41DD-B091-8B05913C7F86}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,12 +93,59 @@ Global
{AD26407A-1944-4507-A296-56338B4AF0EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD26407A-1944-4507-A296-56338B4AF0EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD26407A-1944-4507-A296-56338B4AF0EA}.Release|Any CPU.Build.0 = Release|Any CPU
{29CF069B-FEA0-46F7-92BD-50F5DBF0F8EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29CF069B-FEA0-46F7-92BD-50F5DBF0F8EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29CF069B-FEA0-46F7-92BD-50F5DBF0F8EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29CF069B-FEA0-46F7-92BD-50F5DBF0F8EB}.Release|Any CPU.Build.0 = Release|Any CPU
{B91407BE-E86E-41E0-855B-130B253C1F57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B91407BE-E86E-41E0-855B-130B253C1F57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B91407BE-E86E-41E0-855B-130B253C1F57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B91407BE-E86E-41E0-855B-130B253C1F57}.Release|Any CPU.Build.0 = Release|Any CPU
{69B2C5B9-1E0A-482E-93EA-ED21A76B4637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69B2C5B9-1E0A-482E-93EA-ED21A76B4637}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69B2C5B9-1E0A-482E-93EA-ED21A76B4637}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69B2C5B9-1E0A-482E-93EA-ED21A76B4637}.Release|Any CPU.Build.0 = Release|Any CPU
{0DDA6F82-A578-4B88-8526-0BBECD242DFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DDA6F82-A578-4B88-8526-0BBECD242DFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DDA6F82-A578-4B88-8526-0BBECD242DFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DDA6F82-A578-4B88-8526-0BBECD242DFD}.Release|Any CPU.Build.0 = Release|Any CPU
{6B5E7976-7C2E-48AB-9024-42568293D77A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B5E7976-7C2E-48AB-9024-42568293D77A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B5E7976-7C2E-48AB-9024-42568293D77A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B5E7976-7C2E-48AB-9024-42568293D77A}.Release|Any CPU.Build.0 = Release|Any CPU
{CB833795-0369-47F9-B3C5-599913EDF40D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB833795-0369-47F9-B3C5-599913EDF40D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB833795-0369-47F9-B3C5-599913EDF40D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB833795-0369-47F9-B3C5-599913EDF40D}.Release|Any CPU.Build.0 = Release|Any CPU
{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3}.Release|Any CPU.Build.0 = Release|Any CPU
{D4F525BB-2B19-484D-B78C-8840B527C64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4F525BB-2B19-484D-B78C-8840B527C64F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4F525BB-2B19-484D-B78C-8840B527C64F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4F525BB-2B19-484D-B78C-8840B527C64F}.Release|Any CPU.Build.0 = Release|Any CPU
{6195C8D9-5A94-4ECB-A3E2-85F230153724}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6195C8D9-5A94-4ECB-A3E2-85F230153724}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6195C8D9-5A94-4ECB-A3E2-85F230153724}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6195C8D9-5A94-4ECB-A3E2-85F230153724}.Release|Any CPU.Build.0 = Release|Any CPU
{666E075A-F8DD-41DD-B091-8B05913C7F86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{666E075A-F8DD-41DD-B091-8B05913C7F86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{666E075A-F8DD-41DD-B091-8B05913C7F86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{666E075A-F8DD-41DD-B091-8B05913C7F86}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FA17F2BF-3BAD-4AC4-A970-16E7C81D2852} = {61D62A6C-0B81-48F7-8204-76924E273C7D}
{B91407BE-E86E-41E0-855B-130B253C1F57} = {1E83E25F-0817-44AC-9432-C259839E1028}
{69B2C5B9-1E0A-482E-93EA-ED21A76B4637} = {1E83E25F-0817-44AC-9432-C259839E1028}
{0DDA6F82-A578-4B88-8526-0BBECD242DFD} = {1E83E25F-0817-44AC-9432-C259839E1028}
{6B5E7976-7C2E-48AB-9024-42568293D77A} = {1E83E25F-0817-44AC-9432-C259839E1028}
{CB833795-0369-47F9-B3C5-599913EDF40D} = {1E83E25F-0817-44AC-9432-C259839E1028}
{6A5E43BF-1A2C-4EA9-855C-2555F2CA74B3} = {1E83E25F-0817-44AC-9432-C259839E1028}
{D4F525BB-2B19-484D-B78C-8840B527C64F} = {1E83E25F-0817-44AC-9432-C259839E1028}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8A4B0755-4E1A-46B2-A3CF-245702E48290}
Expand Down
31 changes: 31 additions & 0 deletions sample/Totem.Financial.Api/Controllers/BalanceController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading.Tasks;
using Acme.ProductImport;
using Acme.ProductImport.Queries;
using Microsoft.AspNetCore.Mvc;
using Totem.Timeline.Mvc;

namespace Totem.Sample.Api.Controllers
{
[ApiController]
public class BalanceController : ControllerBase
{
[HttpGet("/api/balance")]
public Task<IActionResult> GetStatus([FromServices] IQueryServer queries)
{
return queries.Get<BalanceQuery>();
}

[HttpPost("/api/balance")]
public Task<IActionResult> SetBalance([FromServices] ICommandServer commands, SetBalanceRequest request)
{
return commands.Execute(
new SetBalance(request.Balance),
When<BalanceSet>.ThenOk);
}
}

public class SetBalanceRequest
{
public int Balance { get; set; }
}
}
24 changes: 24 additions & 0 deletions sample/Totem.Financial.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Totem.Sample.Api
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
29 changes: 29 additions & 0 deletions sample/Totem.Financial.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62432",
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Totem.Financial.Api": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
70 changes: 70 additions & 0 deletions sample/Totem.Financial.Api/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Acme.ProductImport;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Totem.Runtime.Hosting;
using Totem.Timeline.Client;
using Totem.Timeline.Hosting;
using Totem.Timeline.Mvc;
using Totem.Timeline.StreamsDb.Hosting;

namespace Totem.Sample.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
});

services.AddTotemRuntime();

services.AddTimelineClient<FinancialArea>(timeline =>
{
timeline.AddStreamsDb("", "sample21");
});

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IQueryServer, QueryServer>();
services.AddScoped<ICommandServer, CommandServer>();
services.AddSingleton<IQueryNotifier, EmptyQueryNotifier>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseMvc();

// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
}
}
}
24 changes: 24 additions & 0 deletions sample/Totem.Financial.Api/Totem.Financial.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App">
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Totem.Timeline.Mvc\Totem.Timeline.Mvc.csproj" />
<ProjectReference Include="..\..\src\Totem.Timeline.StreamsDb\Totem.Timeline.StreamsDb.csproj" />
<ProjectReference Include="..\..\src\Totem.Timeline\Totem.Timeline.csproj" />
<ProjectReference Include="..\Totem.Financial\Totem.Financial.csproj" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions sample/Totem.Financial.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions sample/Totem.Financial.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Totem.EventBus;

namespace Totem.Financial.Integration
{
public class ImportStartedIntegrationEvent: IntegrationEvent
{
}
}
23 changes: 23 additions & 0 deletions sample/Totem.Financial.Integration/IntegrationEventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Acme.ProductImport;
using System.Threading.Tasks;
using Totem.EventBus;
using Totem.Timeline.Client;

namespace Totem.Financial.Integration
{
public class IntegrationEventHandler:
IIntegrationEventHandler<ImportStartedIntegrationEvent>
{
private readonly IClientDb _clientDb;

public IntegrationEventHandler(IClientDb clientDb)
{
_clientDb = clientDb;
}

public async Task Handle(ImportStartedIntegrationEvent @event)
{
await _clientDb.WriteEvent(new BalanceSet(10));
}
}
}
50 changes: 50 additions & 0 deletions sample/Totem.Financial.Integration/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Acme.ProductImport;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using Totem.EventBus;
using Totem.EventBus.StreamsDb;
using Totem.Runtime.Hosting;
using Totem.Timeline.Client;
using Totem.Timeline.Hosting;
using Totem.Timeline.StreamsDb.Hosting;

namespace Totem.Financial.Integration
{
class Program
{
static async Task Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureHostConfiguration(configHost =>
{
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
})
.ConfigureLogging((hostingContext, logging) =>
{
})
.ConfigureServices((hostContext, services) =>
{
services.AddTotemRuntime();

services.AddTimelineClient<FinancialArea>(timeline =>
{
timeline.AddStreamsDb("", "sample21-financial");
});

services.AddEventBus(eventBus =>
{
eventBus.AddStreamsDb("", "sample21-eventbus");

eventBus.Subscribe<ImportStartedIntegrationEvent, IntegrationEventHandler>(nameof(ImportStartedIntegrationEvent));
});

services.AddSingleton<IQueryNotifier, EmptyQueryNotifier>();
});

await builder.RunConsoleAsync();
}
}
}
Loading