♻️ Still don't know what I am doing. But basically the microservices are done.
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
using DysonNetwork.Drive;
|
using DysonNetwork.Drive;
|
||||||
using DysonNetwork.Drive.Startup;
|
using DysonNetwork.Drive.Startup;
|
||||||
using DysonNetwork.Pusher.Startup;
|
|
||||||
using DysonNetwork.Shared.Auth;
|
using DysonNetwork.Shared.Auth;
|
||||||
|
using DysonNetwork.Shared.Http;
|
||||||
using DysonNetwork.Shared.Registry;
|
using DysonNetwork.Shared.Registry;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -85,9 +85,10 @@ public static class ServiceCollectionExtensions
|
|||||||
options.SwaggerDoc("v1", new OpenApiInfo
|
options.SwaggerDoc("v1", new OpenApiInfo
|
||||||
{
|
{
|
||||||
Version = "v1",
|
Version = "v1",
|
||||||
Title = "DysonNetwork.Drive API",
|
Title = "Dyson Drive",
|
||||||
Description = "DysonNetwork Drive Service",
|
Description =
|
||||||
TermsOfService = new Uri("https://example.com/terms"), // Update with actual terms
|
"The file service of the Dyson Network. Mainly handling file storage and sharing. Also provide image processing and media analysis. Powered the Solar Network Drive as well.",
|
||||||
|
TermsOfService = new Uri("https://solsynth.dev/terms"), // Update with actual terms
|
||||||
License = new OpenApiLicense
|
License = new OpenApiLicense
|
||||||
{
|
{
|
||||||
Name = "APGLv3", // Update with actual license
|
Name = "APGLv3", // Update with actual license
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"App": "Host=localhost;Port=5432;Database=dyson_network;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60",
|
"App": "Host=localhost;Port=5432;Database=dyson_drive;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60",
|
||||||
"FastRetrieve": "localhost:6379",
|
"FastRetrieve": "localhost:6379",
|
||||||
"Etcd": "etcd.orb.local:2379"
|
"Etcd": "etcd.orb.local:2379"
|
||||||
},
|
},
|
||||||
@ -129,7 +129,7 @@
|
|||||||
],
|
],
|
||||||
"Service": {
|
"Service": {
|
||||||
"Name": "DysonNetwork.Drive",
|
"Name": "DysonNetwork.Drive",
|
||||||
"Url": "http://localhost:5216",
|
"Url": "https://localhost:7092",
|
||||||
"ClientCert": "../Certificates/client.crt",
|
"ClientCert": "../Certificates/client.crt",
|
||||||
"ClientKey": "../Certificates/client.key"
|
"ClientKey": "../Certificates/client.key"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using DysonNetwork.Pass;
|
using DysonNetwork.Pass;
|
||||||
using DysonNetwork.Pass.Account;
|
using DysonNetwork.Pass.Account;
|
||||||
using DysonNetwork.Pass.Startup;
|
using DysonNetwork.Pass.Startup;
|
||||||
|
using DysonNetwork.Shared.Http;
|
||||||
using DysonNetwork.Shared.Registry;
|
using DysonNetwork.Shared.Registry;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
namespace DysonNetwork.Pass.Startup;
|
|
||||||
|
|
||||||
public static class KestrelConfiguration
|
|
||||||
{
|
|
||||||
public static WebApplicationBuilder ConfigureAppKestrel(this WebApplicationBuilder builder)
|
|
||||||
{
|
|
||||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
|
||||||
builder.WebHost.ConfigureKestrel(options =>
|
|
||||||
{
|
|
||||||
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
|
||||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
|
||||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
|
||||||
});
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
|
@ -132,8 +132,8 @@ public static class ServiceCollectionExtensions
|
|||||||
options.SwaggerDoc("v1", new OpenApiInfo
|
options.SwaggerDoc("v1", new OpenApiInfo
|
||||||
{
|
{
|
||||||
Version = "v1",
|
Version = "v1",
|
||||||
Title = "Solar Network API",
|
Title = "Dyson Pass",
|
||||||
Description = "An open-source social network",
|
Description = "The authentication service of the Dyson Network. Mainly handling authentication and authorization.",
|
||||||
TermsOfService = new Uri("https://solsynth.dev/terms"),
|
TermsOfService = new Uri("https://solsynth.dev/terms"),
|
||||||
License = new OpenApiLicense
|
License = new OpenApiLicense
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
],
|
],
|
||||||
"Service": {
|
"Service": {
|
||||||
"Name": "DysonNetwork.Pass",
|
"Name": "DysonNetwork.Pass",
|
||||||
"Url": "http://localhost:5216",
|
"Url": "https://localhost:7058",
|
||||||
"ClientCert": "../Certificates/client.crt",
|
"ClientCert": "../Certificates/client.crt",
|
||||||
"ClientKey": "../Certificates/client.key"
|
"ClientKey": "../Certificates/client.key"
|
||||||
},
|
},
|
||||||
|
@ -84,8 +84,8 @@ public static class ServiceCollectionExtensions
|
|||||||
options.SwaggerDoc("v1", new OpenApiInfo
|
options.SwaggerDoc("v1", new OpenApiInfo
|
||||||
{
|
{
|
||||||
Version = "v1",
|
Version = "v1",
|
||||||
Title = "Solar Network API",
|
Title = "Dyson Pusher",
|
||||||
Description = "An open-source social network",
|
Description = "The pusher service of the Dyson Network. Mainly handling emailing, notifications and websockets.",
|
||||||
TermsOfService = new Uri("https://solsynth.dev/terms"),
|
TermsOfService = new Uri("https://solsynth.dev/terms"),
|
||||||
License = new OpenApiLicense
|
License = new OpenApiLicense
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
],
|
],
|
||||||
"Service": {
|
"Service": {
|
||||||
"Name": "DysonNetwork.Pusher",
|
"Name": "DysonNetwork.Pusher",
|
||||||
"Url": "http://localhost:5212",
|
"Url": "https://localhost:7259",
|
||||||
"ClientCert": "../Certificates/client.crt",
|
"ClientCert": "../Certificates/client.crt",
|
||||||
"ClientKey": "../Certificates/client.key"
|
"ClientKey": "../Certificates/client.key"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
namespace DysonNetwork.Pusher.Startup;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
namespace DysonNetwork.Shared.Http;
|
||||||
|
|
||||||
public static class KestrelConfiguration
|
public static class KestrelConfiguration
|
||||||
{
|
{
|
||||||
@ -10,6 +15,10 @@ public static class KestrelConfiguration
|
|||||||
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
||||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
||||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
||||||
|
options.ConfigureEndpointDefaults(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.Protocols = HttpProtocols.Http1AndHttp2;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return builder;
|
return builder;
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Net;
|
||||||
using Grpc.Net.Client;
|
using Grpc.Net.Client;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
@ -16,11 +17,14 @@ public static class GrpcClientHelper
|
|||||||
{
|
{
|
||||||
var handler = new HttpClientHandler();
|
var handler = new HttpClientHandler();
|
||||||
handler.ClientCertificates.Add(
|
handler.ClientCertificates.Add(
|
||||||
clientCertPassword is null ?
|
clientCertPassword is null
|
||||||
X509Certificate2.CreateFromPemFile(clientCertPath, clientKeyPath) :
|
? X509Certificate2.CreateFromPemFile(clientCertPath, clientKeyPath)
|
||||||
X509Certificate2.CreateFromEncryptedPemFile(clientCertPath, clientCertPassword, clientKeyPath)
|
: X509Certificate2.CreateFromEncryptedPemFile(clientCertPath, clientCertPassword, clientKeyPath)
|
||||||
);
|
);
|
||||||
return GrpcChannel.ForAddress(url, new GrpcChannelOptions { HttpHandler = handler }).CreateCallInvoker();
|
var httpClient = new HttpClient(handler);
|
||||||
|
httpClient.DefaultRequestVersion = HttpVersion.Version20;
|
||||||
|
httpClient.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
|
||||||
|
return GrpcChannel.ForAddress(url, new GrpcChannelOptions { HttpClient = httpClient }).CreateCallInvoker();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<string> GetServiceUrlFromEtcd(IEtcdClient etcdClient, string serviceName)
|
private static async Task<string> GetServiceUrlFromEtcd(IEtcdClient etcdClient, string serviceName)
|
||||||
@ -30,6 +34,7 @@ public static class GrpcClientHelper
|
|||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Service '{serviceName}' not found in Etcd.");
|
throw new InvalidOperationException($"Service '{serviceName}' not found in Etcd.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.Kvs[0].Value.ToStringUtf8();
|
return response.Kvs[0].Value.ToStringUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user