Open joni7777 opened 5 years ago
Consider creating a ConfigurationSource for the endpoint-services configuration something like this:
public class BpEndPointerConfigurationSource : IConfigurationSource
{
public string ConfigurationService { get; }
public HttpClient HttpClient { get; }
public TimeSpan Interval { get; }
public BpEndPointerConfigurationSource(string configurationService, HttpClient httpClient, TimeSpan interval)
{
ConfigurationService = configurationService;
HttpClient = httpClient;
Interval = interval;
}
public IConfigurationProvider Build(IConfigurationBuilder builder) => new BpEndPointerConfigurationProvider(this);
}
public class BpEndPointerConfigurationProvider : ConfigurationProvider
{
public BpEndPointerConfigurationSource Source { get; set; }
public BpEndPointerConfigurationProvider(BpEndPointerConfigurationSource source) => Source = source;
public override async void Load()
{
var response = await Source.HttpClient.GetAsync(Source.ConfigurationService);
using (var streamReader = new StreamReader(await response.Content.ReadAsStreamAsync()))
using (var jsonReader = new JsonTextReader(streamReader))
{
var json = await JToken.ReadFromAsync(jsonReader);
var services = json.ToObject<BpEndPointerResponse[]>();
foreach(var service in services)
{
Set($"EndPointer:{service.Name}", service.Url);
}
}
}
}
public class BpEndPointerResponse
{
public string Name { get; set; }
public string Url { get; set; }
}
Create endpointer and swagger-client services to allow using other microservices by service name, and operation id on the service
Current idea for implementing the abillity to have swagger client for different services:
Creating nuget package named: Bp.Endpointer the package reads the config for the endpointer url have register method
Each service should be a nuget package compiled with AutoRest based on the swagger.json file, and after generating the SDK for javascript, typescript, C# - the output will be uploaded to nuget source and npm source so every service will be a package and the c# sdk will extension method of the nuget package Bp.Endpointer
for example
var loginResponse = await Bp.Endpointer.AuthService.Login("username", "password");
This issue requires creating package.json script for generating sdk and dotnet script as well the script will also publish the current sdk files to the npm, nuget under as Bp.ServiceName with version from the service config and the branch name, and if the branch is mater it will uploaded without the branch name
also to add a git hook for each service that on push to the master to run the script
and like this, every service that wants to connect with another will install the Bp.Endpointer and the Bp.ServiceName