diff --git a/DysonNetwork.Control/AppHost.cs b/DysonNetwork.Control/AppHost.cs deleted file mode 100644 index 5e7a99a..0000000 --- a/DysonNetwork.Control/AppHost.cs +++ /dev/null @@ -1,77 +0,0 @@ -using Microsoft.Extensions.Hosting; - -var builder = DistributedApplication.CreateBuilder(args); - -var isDev = builder.Environment.IsDevelopment(); - -var cache = builder.AddRedis("cache"); -var queue = builder.AddNats("queue").WithJetStream(); - -var ringService = builder.AddProject("ring"); -var passService = builder.AddProject("pass") - .WithReference(ringService); -var driveService = builder.AddProject("drive") - .WithReference(passService) - .WithReference(ringService); -var sphereService = builder.AddProject("sphere") - .WithReference(passService) - .WithReference(ringService) - .WithReference(driveService); -var developService = builder.AddProject("develop") - .WithReference(passService) - .WithReference(ringService) - .WithReference(sphereService); -var insightService = builder.AddProject("insight") - .WithReference(passService) - .WithReference(ringService) - .WithReference(sphereService) - .WithReference(developService); -var zoneService = builder.AddProject("zone") - .WithReference(passService) - .WithReference(ringService) - .WithReference(sphereService) - .WithReference(developService) - .WithReference(insightService); - -passService.WithReference(developService).WithReference(driveService); - -List> services = - [ringService, passService, driveService, sphereService, developService, insightService, zoneService]; - -for (var idx = 0; idx < services.Count; idx++) -{ - var service = services[idx]; - - service.WithReference(cache).WithReference(queue); - - var grpcPort = 7002 + idx; - - if (isDev) - { - service.WithEnvironment("GRPC_PORT", grpcPort.ToString()); - - var httpPort = 8001 + idx; - service.WithEnvironment("HTTP_PORTS", httpPort.ToString()); - service.WithHttpEndpoint(httpPort, targetPort: null, isProxied: false, name: "http"); - } - else - { - service.WithHttpEndpoint(8080, targetPort: null, isProxied: false, name: "http"); - } - - service.WithEndpoint(isDev ? grpcPort : 7001, isDev ? null : 7001, "https", name: "grpc", isProxied: false); -} - -// Extra double-ended references -ringService.WithReference(passService); - -var gateway = builder.AddProject("gateway") - .WithEnvironment("HTTP_PORTS", "5001") - .WithHttpEndpoint(port: 5001, targetPort: null, isProxied: false, name: "http"); - -foreach (var service in services) - gateway.WithReference(service); - -builder.AddDockerComposeEnvironment("docker-compose"); - -builder.Build().Run(); diff --git a/DysonNetwork.Control/DysonNetwork.Control.csproj b/DysonNetwork.Control/DysonNetwork.Control.csproj deleted file mode 100644 index b7cd849..0000000 --- a/DysonNetwork.Control/DysonNetwork.Control.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Exe - net10.0 - enable - enable - a68b3195-a00d-40c2-b5ed-d675356b7cde - DysonNetwork.Control - - - - - - - - - - - - - - - - - - - diff --git a/DysonNetwork.Control/Properties/launchSettings.json b/DysonNetwork.Control/Properties/launchSettings.json deleted file mode 100644 index b445d76..0000000 --- a/DysonNetwork.Control/Properties/launchSettings.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "https://localhost:17169;http://localhost:15057", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "DOTNET_ENVIRONMENT": "Development", - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21175", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22189", - "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21260", - "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22052" - } - }, - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:15057", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "DOTNET_ENVIRONMENT": "Development", - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19163", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20185", - "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:22108" - } - } - } -} \ No newline at end of file diff --git a/DysonNetwork.Control/appsettings.json b/DysonNetwork.Control/appsettings.json deleted file mode 100644 index 1bdb86e..0000000 --- a/DysonNetwork.Control/appsettings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "ConnectionStrings": { - "cache": "localhost:6379" - } -} diff --git a/DysonNetwork.Control/aspire-manifest.json b/DysonNetwork.Control/aspire-manifest.json deleted file mode 100644 index 69ad8b5..0000000 --- a/DysonNetwork.Control/aspire-manifest.json +++ /dev/null @@ -1,357 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/aspire-8.0.json", - "resources": { - "cache": { - "type": "container.v1", - "connectionString": "{cache.bindings.tcp.host}:{cache.bindings.tcp.port},password={cache-password.value}", - "image": "docker.io/library/redis:8.2", - "entrypoint": "/bin/sh", - "args": [ - "-c", - "redis-server --requirepass $REDIS_PASSWORD" - ], - "env": { - "REDIS_PASSWORD": "{cache-password.value}" - }, - "bindings": { - "tcp": { - "scheme": "tcp", - "protocol": "tcp", - "transport": "tcp", - "targetPort": 6379 - } - } - }, - "queue": { - "type": "container.v1", - "connectionString": "nats://nats:{queue-password.value}@{queue.bindings.tcp.host}:{queue.bindings.tcp.port}", - "image": "docker.io/library/nats:2.11", - "args": [ - "--user", - "nats", - "--pass", - "{queue-password.value}", - "-js" - ], - "bindings": { - "tcp": { - "scheme": "tcp", - "protocol": "tcp", - "transport": "tcp", - "targetPort": 4222 - } - } - }, - "ring": { - "type": "project.v1", - "path": "../DysonNetwork.Ring/DysonNetwork.Ring.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8001", - "HTTPS_PORTS": "{ring.bindings.grpc.targetPort}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7002", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "ring" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8001 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7002 - } - } - }, - "pass": { - "type": "project.v1", - "path": "../DysonNetwork.Pass/DysonNetwork.Pass.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8002", - "HTTPS_PORTS": "{pass.bindings.grpc.targetPort}", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "services__develop__http__0": "{develop.bindings.http.url}", - "services__develop__grpc__0": "{develop.bindings.grpc.url}", - "services__drive__http__0": "{drive.bindings.http.url}", - "services__drive__grpc__0": "{drive.bindings.grpc.url}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7003", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "pass" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8002 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7003 - } - } - }, - "drive": { - "type": "project.v1", - "path": "../DysonNetwork.Drive/DysonNetwork.Drive.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8003", - "HTTPS_PORTS": "{drive.bindings.grpc.targetPort}", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7004", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "drive" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8003 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7004 - } - } - }, - "sphere": { - "type": "project.v1", - "path": "../DysonNetwork.Sphere/DysonNetwork.Sphere.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8004", - "HTTPS_PORTS": "{sphere.bindings.grpc.targetPort}", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "services__drive__http__0": "{drive.bindings.http.url}", - "services__drive__grpc__0": "{drive.bindings.grpc.url}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7005", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "sphere" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8004 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7005 - } - } - }, - "develop": { - "type": "project.v1", - "path": "../DysonNetwork.Develop/DysonNetwork.Develop.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8005", - "HTTPS_PORTS": "{develop.bindings.grpc.targetPort}", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "services__sphere__http__0": "{sphere.bindings.http.url}", - "services__sphere__grpc__0": "{sphere.bindings.grpc.url}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7006", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "develop" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8005 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7006 - } - } - }, - "insight": { - "type": "project.v1", - "path": "../DysonNetwork.Insight/DysonNetwork.Insight.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "8006", - "HTTPS_PORTS": "{insight.bindings.grpc.targetPort}", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "services__sphere__http__0": "{sphere.bindings.http.url}", - "services__sphere__grpc__0": "{sphere.bindings.grpc.url}", - "services__develop__http__0": "{develop.bindings.http.url}", - "services__develop__grpc__0": "{develop.bindings.grpc.url}", - "ConnectionStrings__cache": "{cache.connectionString}", - "ConnectionStrings__queue": "{queue.connectionString}", - "GRPC_PORT": "7007", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "insight" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 8006 - }, - "grpc": { - "scheme": "https", - "protocol": "tcp", - "transport": "http", - "targetPort": 7007 - } - } - }, - "gateway": { - "type": "project.v1", - "path": "../DysonNetwork.Gateway/DysonNetwork.Gateway.csproj", - "env": { - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", - "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", - "HTTP_PORTS": "5001", - "services__ring__http__0": "{ring.bindings.http.url}", - "services__ring__grpc__0": "{ring.bindings.grpc.url}", - "services__pass__http__0": "{pass.bindings.http.url}", - "services__pass__grpc__0": "{pass.bindings.grpc.url}", - "services__drive__http__0": "{drive.bindings.http.url}", - "services__drive__grpc__0": "{drive.bindings.grpc.url}", - "services__sphere__http__0": "{sphere.bindings.http.url}", - "services__sphere__grpc__0": "{sphere.bindings.grpc.url}", - "services__develop__http__0": "{develop.bindings.http.url}", - "services__develop__grpc__0": "{develop.bindings.grpc.url}", - "services__insight__http__0": "{insight.bindings.http.url}", - "services__insight__grpc__0": "{insight.bindings.grpc.url}", - "OTEL_EXPORTER_OTLP_ENDPOINT": "{docker-compose-dashboard.bindings.otlp-grpc.url}", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", - "OTEL_SERVICE_NAME": "gateway" - }, - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 5001 - } - } - }, - "docker-compose": { - "error": "This resource does not support generation in the manifest." - }, - "cache-password": { - "type": "parameter.v0", - "value": "{cache-password.inputs.value}", - "inputs": { - "value": { - "type": "string", - "secret": true, - "default": { - "generate": { - "minLength": 22, - "special": false - } - } - } - } - }, - "queue-password": { - "type": "parameter.v0", - "value": "{queue-password.inputs.value}", - "inputs": { - "value": { - "type": "string", - "secret": true, - "default": { - "generate": { - "minLength": 22, - "special": false - } - } - } - } - }, - "docker-compose-dashboard": { - "type": "container.v1", - "image": "mcr.microsoft.com/dotnet/nightly/aspire-dashboard:latest", - "bindings": { - "http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 18888 - }, - "otlp-grpc": { - "scheme": "http", - "protocol": "tcp", - "transport": "http", - "targetPort": 18889 - } - } - } - } -} \ No newline at end of file diff --git a/DysonNetwork.Pass/Account/AccountController.cs b/DysonNetwork.Pass/Account/AccountController.cs index def2d91..624d736 100644 --- a/DysonNetwork.Pass/Account/AccountController.cs +++ b/DysonNetwork.Pass/Account/AccountController.cs @@ -5,7 +5,7 @@ using DysonNetwork.Pass.Credit; using DysonNetwork.Pass.Permission; using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Auth; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Http; using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Authorization; @@ -25,7 +25,7 @@ public class AccountController( AccountEventService events, SocialCreditService socialCreditService, AffiliationSpellService ars, - GeoIpService geo + GeoService geo ) : ControllerBase { [HttpGet("{name}")] diff --git a/DysonNetwork.Pass/Account/ActionLogService.cs b/DysonNetwork.Pass/Account/ActionLogService.cs index 9801b3d..4ed1eb8 100644 --- a/DysonNetwork.Pass/Account/ActionLogService.cs +++ b/DysonNetwork.Pass/Account/ActionLogService.cs @@ -1,10 +1,10 @@ using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Account; -public class ActionLogService(GeoIpService geo, FlushBufferService fbs) +public class ActionLogService(GeoService geo, FlushBufferService fbs) { public void CreateActionLog(Guid accountId, string action, Dictionary meta) { diff --git a/DysonNetwork.Pass/Auth/AuthController.cs b/DysonNetwork.Pass/Auth/AuthController.cs index 2edafec..a0cb2b7 100644 --- a/DysonNetwork.Pass/Auth/AuthController.cs +++ b/DysonNetwork.Pass/Auth/AuthController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc; using NodaTime; using Microsoft.EntityFrameworkCore; using DysonNetwork.Pass.Localization; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Proto; using Microsoft.Extensions.Localization; using AccountService = DysonNetwork.Pass.Account.AccountService; @@ -18,7 +18,7 @@ public class AuthController( AppDatabase db, AccountService accounts, AuthService auth, - GeoIpService geo, + GeoService geo, ActionLogService als, RingService.RingServiceClient pusher, IConfiguration configuration, diff --git a/DysonNetwork.Pass/Auth/AuthService.cs b/DysonNetwork.Pass/Auth/AuthService.cs index a5fafb5..7579190 100644 --- a/DysonNetwork.Pass/Auth/AuthService.cs +++ b/DysonNetwork.Pass/Auth/AuthService.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.Data; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -16,7 +16,7 @@ public class AuthService( IHttpClientFactory httpClientFactory, IHttpContextAccessor httpContextAccessor, ICacheService cache, - GeoIpService geo + GeoService geo ) { private HttpContext HttpContext => httpContextAccessor.HttpContext!; diff --git a/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.cs b/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.cs index f365847..894f089 100644 --- a/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.cs +++ b/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.cs @@ -1,4 +1,4 @@ -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; diff --git a/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.Designer.cs b/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.Designer.cs index f8a4ae1..d3afdd9 100644 --- a/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.cs b/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.cs index 6e857bd..2e002af 100644 --- a/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.cs +++ b/DysonNetwork.Pass/Migrations/20251003061315_AddSubscriptionGift.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.GeoIp; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; diff --git a/DysonNetwork.Pass/Migrations/20251003123103_RefactorSubscriptionRelation.Designer.cs b/DysonNetwork.Pass/Migrations/20251003123103_RefactorSubscriptionRelation.Designer.cs index 53824fd..26c96a4 100644 --- a/DysonNetwork.Pass/Migrations/20251003123103_RefactorSubscriptionRelation.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251003123103_RefactorSubscriptionRelation.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251003152102_AddWalletFund.Designer.cs b/DysonNetwork.Pass/Migrations/20251003152102_AddWalletFund.Designer.cs index d6defee..d23f6fa 100644 --- a/DysonNetwork.Pass/Migrations/20251003152102_AddWalletFund.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251003152102_AddWalletFund.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251008050851_AddUsernameColor.Designer.cs b/DysonNetwork.Pass/Migrations/20251008050851_AddUsernameColor.Designer.cs index 92fc365..946d191 100644 --- a/DysonNetwork.Pass/Migrations/20251008050851_AddUsernameColor.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251008050851_AddUsernameColor.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251021153439_AddRealmFromSphere.Designer.cs b/DysonNetwork.Pass/Migrations/20251021153439_AddRealmFromSphere.Designer.cs index e435aea..f83b2e2 100644 --- a/DysonNetwork.Pass/Migrations/20251021153439_AddRealmFromSphere.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251021153439_AddRealmFromSphere.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251022164134_RemoveChatRoom.Designer.cs b/DysonNetwork.Pass/Migrations/20251022164134_RemoveChatRoom.Designer.cs index 4babc35..276e081 100644 --- a/DysonNetwork.Pass/Migrations/20251022164134_RemoveChatRoom.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251022164134_RemoveChatRoom.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251023173204_AddLotteries.Designer.cs b/DysonNetwork.Pass/Migrations/20251023173204_AddLotteries.Designer.cs index c7e4f3b..5fde9c9 100644 --- a/DysonNetwork.Pass/Migrations/20251023173204_AddLotteries.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251023173204_AddLotteries.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251024154539_AddDetailLotteriesStatus.Designer.cs b/DysonNetwork.Pass/Migrations/20251024154539_AddDetailLotteriesStatus.Designer.cs index 5bdd5ce..d95d0bc 100644 --- a/DysonNetwork.Pass/Migrations/20251024154539_AddDetailLotteriesStatus.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251024154539_AddDetailLotteriesStatus.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251101092348_AddPresenceActivity.Designer.cs b/DysonNetwork.Pass/Migrations/20251101092348_AddPresenceActivity.Designer.cs index 4fdb63e..364eac8 100644 --- a/DysonNetwork.Pass/Migrations/20251101092348_AddPresenceActivity.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251101092348_AddPresenceActivity.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251101142549_EnrichPresenceActivity.Designer.cs b/DysonNetwork.Pass/Migrations/20251101142549_EnrichPresenceActivity.Designer.cs index 581cbdb..35d5d1d 100644 --- a/DysonNetwork.Pass/Migrations/20251101142549_EnrichPresenceActivity.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251101142549_EnrichPresenceActivity.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251101175500_AddSocialCreditRecordStatus.Designer.cs b/DysonNetwork.Pass/Migrations/20251101175500_AddSocialCreditRecordStatus.Designer.cs index 0b0c653..b578f76 100644 --- a/DysonNetwork.Pass/Migrations/20251101175500_AddSocialCreditRecordStatus.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251101175500_AddSocialCreditRecordStatus.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251116153151_OpenableFunds.Designer.cs b/DysonNetwork.Pass/Migrations/20251116153151_OpenableFunds.Designer.cs index ff63da6..18dcefa 100644 --- a/DysonNetwork.Pass/Migrations/20251116153151_OpenableFunds.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251116153151_OpenableFunds.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251116163407_OpenFundsTotalSplits.Designer.cs b/DysonNetwork.Pass/Migrations/20251116163407_OpenFundsTotalSplits.Designer.cs index aa4876c..ca5df1c 100644 --- a/DysonNetwork.Pass/Migrations/20251116163407_OpenFundsTotalSplits.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251116163407_OpenFundsTotalSplits.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251129095046_DecoupleAuthSessionAndChallenge.Designer.cs b/DysonNetwork.Pass/Migrations/20251129095046_DecoupleAuthSessionAndChallenge.Designer.cs index dac7979..afcee60 100644 --- a/DysonNetwork.Pass/Migrations/20251129095046_DecoupleAuthSessionAndChallenge.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251129095046_DecoupleAuthSessionAndChallenge.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251201145617_AddAffiliationSpell.Designer.cs b/DysonNetwork.Pass/Migrations/20251201145617_AddAffiliationSpell.Designer.cs index 959e4f1..fff27e1 100644 --- a/DysonNetwork.Pass/Migrations/20251201145617_AddAffiliationSpell.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251201145617_AddAffiliationSpell.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251202134035_SimplifiedPermissionNode.Designer.cs b/DysonNetwork.Pass/Migrations/20251202134035_SimplifiedPermissionNode.Designer.cs index 52598be..a58eb52 100644 --- a/DysonNetwork.Pass/Migrations/20251202134035_SimplifiedPermissionNode.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251202134035_SimplifiedPermissionNode.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251202160759_SimplifiedAuthSession.Designer.cs b/DysonNetwork.Pass/Migrations/20251202160759_SimplifiedAuthSession.Designer.cs index fa5cc67..0c1217c 100644 --- a/DysonNetwork.Pass/Migrations/20251202160759_SimplifiedAuthSession.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251202160759_SimplifiedAuthSession.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.Designer.cs b/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.Designer.cs index a71ee3b..459b946 100644 --- a/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.cs b/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.cs index 2afe6eb..ff64456 100644 --- a/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.cs +++ b/DysonNetwork.Pass/Migrations/20251203163459_AddLocationToSession.cs @@ -1,4 +1,4 @@ -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs b/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs index a2f3dd7..9c5cba0 100644 --- a/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs +++ b/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs index cdeb908..e2d352f 100644 --- a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs @@ -23,7 +23,7 @@ using DysonNetwork.Pass.Realm; using DysonNetwork.Pass.Safety; using DysonNetwork.Pass.Wallet.PaymentHandlers; using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Registry; namespace DysonNetwork.Pass.Startup; @@ -136,7 +136,7 @@ public static class ServiceCollectionExtensions { services.AddScoped(); services.Configure(configuration.GetSection("GeoIP")); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/DysonNetwork.Shared/DysonNetwork.Shared.csproj b/DysonNetwork.Shared/DysonNetwork.Shared.csproj index a9f23fa..efabbfb 100644 --- a/DysonNetwork.Shared/DysonNetwork.Shared.csproj +++ b/DysonNetwork.Shared/DysonNetwork.Shared.csproj @@ -8,6 +8,7 @@ + diff --git a/DysonNetwork.Shared/Extensions.cs b/DysonNetwork.Shared/Extensions.cs index da8f1e9..c7b4b12 100644 --- a/DysonNetwork.Shared/Extensions.cs +++ b/DysonNetwork.Shared/Extensions.cs @@ -1,4 +1,6 @@ +using dotnet_etcd; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Registry; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.Configuration; @@ -51,9 +53,12 @@ public static class Extensions // }); builder.Services.AddSingleton(SystemClock.Instance); + builder.Services.AddSingleton(new EtcdClient(builder.Configuration.GetConnectionString("Registrar"))); + builder.Services.AddSingleton(); + builder.Services.AddHostedService(); - builder.AddNatsClient("queue"); - builder.AddRedisClient("cache", configureOptions: opts => { opts.AbortOnConnectFail = false; }); + builder.AddNatsClient("Queue"); + builder.AddRedisClient("Cache", configureOptions: opts => { opts.AbortOnConnectFail = false; }); // Setup cache service builder.Services.AddStackExchangeRedisCache(options => diff --git a/DysonNetwork.Shared/GeoIp/GeoPoint.cs b/DysonNetwork.Shared/Geometry/GeoPoint.cs similarity index 85% rename from DysonNetwork.Shared/GeoIp/GeoPoint.cs rename to DysonNetwork.Shared/Geometry/GeoPoint.cs index 8c8b04e..adc4382 100644 --- a/DysonNetwork.Shared/GeoIp/GeoPoint.cs +++ b/DysonNetwork.Shared/Geometry/GeoPoint.cs @@ -1,4 +1,4 @@ -namespace DysonNetwork.Shared.GeoIp; +namespace DysonNetwork.Shared.Geometry; public class GeoPoint { diff --git a/DysonNetwork.Shared/GeoIp/GeoIpService.cs b/DysonNetwork.Shared/Geometry/GeoService.cs similarity index 93% rename from DysonNetwork.Shared/GeoIp/GeoIpService.cs rename to DysonNetwork.Shared/Geometry/GeoService.cs index a3bdd77..c3a531e 100644 --- a/DysonNetwork.Shared/GeoIp/GeoIpService.cs +++ b/DysonNetwork.Shared/Geometry/GeoService.cs @@ -1,14 +1,14 @@ using MaxMind.GeoIP2; using Microsoft.Extensions.Options; -namespace DysonNetwork.Shared.GeoIp; +namespace DysonNetwork.Shared.Geometry; public class GeoIpOptions { public string DatabasePath { get; set; } = null!; } -public class GeoIpService(IOptions options) +public class GeoService(IOptions options) { private readonly string _databasePath = options.Value.DatabasePath; diff --git a/DysonNetwork.Shared/Models/ActionLog.cs b/DysonNetwork.Shared/Models/ActionLog.cs index 0571ff8..1ec5f76 100644 --- a/DysonNetwork.Shared/Models/ActionLog.cs +++ b/DysonNetwork.Shared/Models/ActionLog.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Proto; using NodaTime.Serialization.Protobuf; diff --git a/DysonNetwork.Shared/Models/AuthSession.cs b/DysonNetwork.Shared/Models/AuthSession.cs index d40926a..c5fcdb3 100644 --- a/DysonNetwork.Shared/Models/AuthSession.cs +++ b/DysonNetwork.Shared/Models/AuthSession.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Shared.Proto; using NodaTime; using NodaTime.Serialization.Protobuf; diff --git a/DysonNetwork.Shared/Registry/ServiceRegistrar.cs b/DysonNetwork.Shared/Registry/ServiceRegistrar.cs new file mode 100644 index 0000000..8f6e55f --- /dev/null +++ b/DysonNetwork.Shared/Registry/ServiceRegistrar.cs @@ -0,0 +1,93 @@ +using dotnet_etcd; +using Etcdserverpb; +using Google.Protobuf; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; + +namespace DysonNetwork.Shared.Registry; + +public class ServiceRegistrar(EtcdClient etcd) +{ + private CancellationTokenSource? _cts; + private string? _serviceKey; + private long _leaseId; + private long _ttlSeconds; + + /// + /// Register the service in etcd with a TTL lease. + /// + public async Task RegisterAsync(string serviceName, string servicePart, string instanceId, string host, int port, long ttlSeconds = 30) + { + _ttlSeconds = ttlSeconds; + _serviceKey = $"/services/{serviceName}/${servicePart}/{instanceId}"; + var serviceValue = $"{host}:{port}"; + + // Create and store TTL lease + var leaseResp = await etcd.LeaseGrantAsync(new LeaseGrantRequest { TTL = _ttlSeconds }); + _leaseId = leaseResp.ID; + + await etcd.PutAsync(new PutRequest() + { + Key = ByteString.CopyFromUtf8(_serviceKey), + Value = ByteString.CopyFromUtf8(serviceValue), + Lease = _leaseId + }); + + // Start a background task to keep the lease alive + _cts = new CancellationTokenSource(); + _ = Task.Run(async () => + { + while (!_cts.Token.IsCancellationRequested) + { + try + { + await etcd.LeaseKeepAlive(_leaseId, _cts.Token); + await Task.Delay(TimeSpan.FromSeconds(_ttlSeconds / 2), _cts.Token); + } + catch (Exception ex) + { + Console.WriteLine($"Error keeping lease alive: {ex.Message}"); + break; + } + } + }, _cts.Token); + } + + + public async Task DeregisterAsync() + { + await _cts?.CancelAsync(); + + if (_serviceKey != null) + { + try + { + await etcd.DeleteAsync(_serviceKey); + } + catch + { + // ignore delete errors + } + } + } +} + +public class ServiceRegistrarHostedService(ServiceRegistrar registrar, IConfiguration config) : IHostedService +{ + public async Task StartAsync(CancellationToken cancellationToken) + { + var name = config["Service:Name"]; + var host = config["Service:Host"]; + var grpcPort = int.Parse(config["Service:GrpcPort"]!); + var httpPort = int.Parse(config["Service:HttpPort"]!); + var instanceId = config["Service:InstanceId"] ?? Guid.NewGuid().ToString("N"); + + await registrar.RegisterAsync(name, "grpc", instanceId, host, grpcPort); + await registrar.RegisterAsync(name, "http", instanceId, host, httpPort); + } + + public async Task StopAsync(CancellationToken cancellationToken) + { + await registrar.DeregisterAsync(); + } +} \ No newline at end of file diff --git a/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs index 7e00870..7f57762 100644 --- a/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Sphere.Autocompletion; using DysonNetwork.Sphere.Chat; using DysonNetwork.Sphere.Chat.Realtime; @@ -88,7 +88,7 @@ public static class ServiceCollectionExtensions ) { services.Configure(configuration.GetSection("GeoIP")); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/DysonNetwork.Zone/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Zone/Startup/ServiceCollectionExtensions.cs index 437730f..e109e24 100644 --- a/DysonNetwork.Zone/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Zone/Startup/ServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Geometry; using DysonNetwork.Zone.Publication; using NodaTime; using NodaTime.Serialization.SystemTextJson; @@ -74,7 +74,7 @@ public static class ServiceCollectionExtensions ) { services.Configure(configuration.GetSection("GeoIP")); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/DysonNetwork.sln b/DysonNetwork.sln index 5123f71..b8afee8 100644 --- a/DysonNetwork.sln +++ b/DysonNetwork.sln @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DysonNetwork.Drive", "Dyson EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DysonNetwork.Develop", "DysonNetwork.Develop\DysonNetwork.Develop.csproj", "{C577AA78-B11D-4076-89A6-1C7F0ECC04E2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DysonNetwork.Control", "DysonNetwork.Control\DysonNetwork.Control.csproj", "{7FFED190-51C7-4302-A8B5-96C839463458}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DysonNetwork.Gateway", "DysonNetwork.Gateway\DysonNetwork.Gateway.csproj", "{AA4D244C-6C3A-4CD0-9DA4-5CAFFBB55085}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DysonNetwork.Insight", "DysonNetwork.Insight\DysonNetwork.Insight.csproj", "{E603CDF2-8BA0-49AE-A1F9-BD2DA5CB983D}" @@ -107,18 +105,6 @@ Global {C577AA78-B11D-4076-89A6-1C7F0ECC04E2}.Release|x64.Build.0 = Release|Any CPU {C577AA78-B11D-4076-89A6-1C7F0ECC04E2}.Release|x86.ActiveCfg = Release|Any CPU {C577AA78-B11D-4076-89A6-1C7F0ECC04E2}.Release|x86.Build.0 = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|x64.ActiveCfg = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|x64.Build.0 = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|x86.ActiveCfg = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Debug|x86.Build.0 = Debug|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|Any CPU.Build.0 = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|x64.ActiveCfg = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|x64.Build.0 = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|x86.ActiveCfg = Release|Any CPU - {7FFED190-51C7-4302-A8B5-96C839463458}.Release|x86.Build.0 = Release|Any CPU {AA4D244C-6C3A-4CD0-9DA4-5CAFFBB55085}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA4D244C-6C3A-4CD0-9DA4-5CAFFBB55085}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA4D244C-6C3A-4CD0-9DA4-5CAFFBB55085}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user index 6cd788c..3d019cd 100644 --- a/DysonNetwork.sln.DotSettings.user +++ b/DysonNetwork.sln.DotSettings.user @@ -52,6 +52,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded