Skip to content

Commit

Permalink
Merge pull request #38 Release 1.0 Master
Browse files Browse the repository at this point in the history
Release 1.0
  • Loading branch information
g-martin772 authored Jun 9, 2024
2 parents b1c9672 + 32f281c commit 110a3e0
Show file tree
Hide file tree
Showing 159 changed files with 11,623 additions and 1,707 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,qodana.sarif.json
args: --baseline,qodana.sarif.json,--property=qodana.net.solution=MPM-Betting.sln
11 changes: 11 additions & 0 deletions .jetclient/Fotmob/League.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```toml
name = 'League'
method = 'GET'
url = 'https://www.fotmob.com/api/leagues?id=47'
sortWeight = 2000000
id = '3e73e76c-092c-423c-a18c-c6851d264c62'

[[queryParams]]
key = 'id'
value = '47'
```
11 changes: 11 additions & 0 deletions .jetclient/Fotmob/MatchDetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```toml
name = 'MatchDetails'
method = 'GET'
url = 'https://www.fotmob.com/api/matchDetails?matchId=4446289'
sortWeight = 1000000
id = 'b4ca69ff-4a3d-4373-ac40-9ab7c28e6d8a'

[[queryParams]]
key = 'matchId'
value = '4446289'
```
5 changes: 5 additions & 0 deletions .jetclient/Fotmob/_folder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```toml
name = 'Fotmob'
sortWeight = 1000000
id = '0d3a8805-8713-4d3e-91a5-fc9c8ab1eba5'
```
8 changes: 8 additions & 0 deletions .jetclient/jetclient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```toml
name = 'MPM'
id = '32129df4-d7b1-4801-9a44-cddb4c41c968'

[[environmentGroups]]
name = 'Default'
environments = []
```
12 changes: 6 additions & 6 deletions MPM-Betting.Api/MPM-Betting.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions MPM-Betting.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Net.Mail;
using Microsoft.EntityFrameworkCore;
using MPM_Betting.DataModel;
using MPM_Betting.Services;
using MPM_Betting.Services.Data;
using MPM_Betting.Services.Data.BetManager;
using MPM_Betting.Services.Data.GameData;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -16,8 +16,15 @@
builder.AddMpmMail();
builder.AddFootballApi();



builder.Services.AddSingleton<BetProcessor>();
builder.Services.AddSingleton<GameDataUpdater>();
builder.Services.AddSingleton<GameDataUpdateScheduler>();
builder.Services.AddSingleton<GameDataQueueWorker>();
builder.Services.AddSingleton<IBackgroundTaskQueue>(_ => new GameDataUpdateQueue(100));
builder.Services.AddHostedService(services => services.GetRequiredService<BetProcessor>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataUpdater>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataUpdateScheduler>());
builder.Services.AddHostedService(services => services.GetRequiredService<GameDataQueueWorker>());

var app = builder.Build();

Expand Down
6 changes: 3 additions & 3 deletions MPM-Betting.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18954",
"applicationUrl": "http://0.0.0.0:18954",
"sslPort": 44303
}
},
Expand All @@ -14,7 +14,7 @@
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5241",
"applicationUrl": "http://0.0.0.0:5241",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand All @@ -24,7 +24,7 @@
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7258;http://localhost:5241",
"applicationUrl": "https://0.0.0.0:7258;http://0.0.0.0:5241",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
7 changes: 3 additions & 4 deletions MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Publishing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.UserSecrets;
Expand Down Expand Up @@ -71,7 +69,8 @@ public static IResourceBuilder<ParameterResource> CreateStablePassword(this IDis
{
ParameterDefault generatedPassword = new GenerateParameterDefault
{
MinLength = 22, // enough to give 128 bits of entropy when using the default 67 possible characters. See remarks in PasswordGenerator.Generate
MinLength = 22, // Enough to give 128 bits of entropy when using the default 67 possible characters.
// See remarks in PasswordGenerator.Generate
Lower = lower,
Upper = upper,
Numeric = numeric,
Expand Down Expand Up @@ -122,7 +121,7 @@ private static bool TrySetUserSecret(string applicationName, string name, string
return false;

var appAssembly = Assembly.Load(new AssemblyName(applicationName));
if (appAssembly?.GetCustomAttribute<UserSecretsIdAttribute>()?.UserSecretsId is not { } userSecretsId)
if (appAssembly.GetCustomAttribute<UserSecretsIdAttribute>()?.UserSecretsId is not { } userSecretsId)
return false;

// Save the value to the secret store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Aspire.Hosting.Azure.Sql" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Aspire.Hosting.Redis" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Aspire.Hosting.SqlServer" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Grpc.AspNetCore" Version="2.62.0" />
<PackageReference Include="KubernetesClient" Version="13.0.37" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.1" />
<PackageReference Include="Aspire.Hosting.Azure.Sql" Version="8.0.1" />
<PackageReference Include="Aspire.Hosting.Redis" Version="8.0.1" />
<PackageReference Include="Aspire.Hosting.SqlServer" Version="8.0.1" />
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Grpc.AspNetCore" Version="2.63.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="Polly" Version="8.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class MailDevResource(string name) : ContainerResource(name), IResourceWithConnectionString
{
private EndpointReference? _smtpReference;
private EndpointReference SmtpEndpoint => _smtpReference ??= new EndpointReference(this, "smtp");
private EndpointReference? m_SmtpReference;
private EndpointReference SmtpEndpoint => m_SmtpReference ??= new EndpointReference(this, "smtp");

public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create(
$"smtp://{SmtpEndpoint.Property(EndpointProperty.Host)}:{SmtpEndpoint.Property(EndpointProperty.Port)}"
Expand Down
22 changes: 12 additions & 10 deletions MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var builder = DistributedApplication.CreateBuilder(args);

if (!builder.ExecutionContext.IsPublishMode)
if (!builder.ExecutionContext.IsPublishMode && Environment.GetEnvironmentVariable("AZF") == "true")
{
var azurite = builder.AddContainer("azurite", "mcr.microsoft.com/azure-storage/azurite")
.WithEndpoint(port: 10000, name: "blob", targetPort: 11000)
Expand All @@ -15,20 +15,22 @@
// .WithReference(queue)
// .WithEnvironment("QueueConnectionString", queueConnStrCallback)

var functions = builder.AddAzureFunction<MPM_Betting_Functions>("functions")
builder.AddAzureFunction<MPM_Betting_Functions>("functions")
.WithReference(azurite.GetEndpoint("queue"))
.WithEnvironment("QueueConnectionString", queueConnStrCallback);
}

if (builder.ExecutionContext.IsPublishMode || Environment.GetEnvironmentVariable("METRICS") == "true")
{
builder.AddContainer("grafana", "grafana/grafana")
.WithBindMount(GetFullPath("../grafana/config"), "/etc/grafana", isReadOnly: false)
.WithBindMount(GetFullPath("../grafana/dashboards"), "/var/lib/grafana/dashboards", isReadOnly: false)
.WithHttpEndpoint(port: 3000, targetPort: 3000, isProxied: false);
builder.AddContainer("prometheus", "prom/prometheus")
.WithBindMount(GetFullPath("../prometheus"), "/etc/prometheus")
.WithHttpEndpoint(port: 9090, targetPort: 9090, isProxied: false);
}

var grafana = builder.AddContainer("grafana", "grafana/grafana")
.WithBindMount(GetFullPath("../grafana/config"), "/etc/grafana", isReadOnly: false)
.WithBindMount(GetFullPath("../grafana/dashboards"), "/var/lib/grafana/dashboards", isReadOnly: false)
.WithHttpEndpoint(port: 3000, targetPort: 3000);

var prometheus = builder.AddContainer("prometheus", "prom/prometheus")
.WithBindMount(GetFullPath("../prometheus"), "/etc/prometheus")
.WithHttpEndpoint(port: 9090, targetPort: 9090);

var redis = builder.AddRedis("redis")
.WithPersistence()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"bindings": {
"grafana-http": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
Expand All @@ -35,18 +35,18 @@
}
],
"bindings": {
"tcp": {
"scheme": "tcp",
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "tcp",
"transport": "http",
"targetPort": 9090
}
}
},
"redis": {
"type": "container.v0",
"connectionString": "{redis.bindings.tcp.host}:{redis.bindings.tcp.port}",
"image": "docker.io/library/redis:7.2.4",
"image": "docker.io/library/redis:7.2",
"args": [
"--save",
"60",
Expand Down Expand Up @@ -81,6 +81,27 @@
"type": "value.v0",
"connectionString": "{sql.connectionString};Database=MPM-Betting"
},
"maildev": {
"type": "container.v0",
"connectionString": "smtp://{maildev.bindings.smtp.host}:{maildev.bindings.smtp.port}",
"image": "docker.io/maildev/maildev:2.0.2",
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"port": 9324,
"targetPort": 1080
},
"smtp": {
"scheme": "tcp",
"protocol": "tcp",
"transport": "tcp",
"port": 9325,
"targetPort": 1025
}
}
},
"api": {
"type": "project.v0",
"path": "../../../MPM-Betting.Api/MPM-Betting.Api.csproj",
Expand All @@ -90,18 +111,21 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"ConnectionStrings__MPM-Betting": "{MPM-Betting.connectionString}",
"ConnectionStrings__redis": "{redis.connectionString}"
"ConnectionStrings__redis": "{redis.connectionString}",
"ConnectionStrings__maildev": "{maildev.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
"transport": "http",
"external": true
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
"transport": "http",
"external": true
}
}
},
Expand All @@ -116,18 +140,21 @@
"services__api__http__0": "{api.bindings.http.url}",
"services__api__https__0": "{api.bindings.https.url}",
"ConnectionStrings__redis": "{redis.connectionString}",
"ConnectionStrings__MPM-Betting": "{MPM-Betting.connectionString}"
"ConnectionStrings__MPM-Betting": "{MPM-Betting.connectionString}",
"ConnectionStrings__maildev": "{maildev.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
"transport": "http",
"external": true
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
"transport": "http",
"external": true
}
}
},
Expand All @@ -139,6 +166,7 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"ConnectionStrings__redis": "{redis.connectionString}",
"ConnectionStrings__MPM-Betting": "{MPM-Betting.connectionString}"
},
"bindings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Prometheus;

namespace Microsoft.Extensions.Hosting;

Expand Down Expand Up @@ -52,7 +51,7 @@ public static IHostBuilder AddServiceDefaults(this IHostBuilder builder)
services.AddOpenTelemetryExporters(context.Configuration);
});

builder.ConfigureServices((context, services) => {
builder.ConfigureServices((_, services) => {
services.AddServiceDiscovery();
services.ConfigureHttpClientDefaults(http =>
{
Expand Down Expand Up @@ -185,7 +184,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
// Add a default liveness check to ensure the app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.8.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.8.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.5" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 110a3e0

Please sign in to comment.