Skip to content

Commit

Permalink
Refactored players svc client uri to env var (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
deesejohn committed Mar 22, 2021
1 parent 08d08fc commit c2cf562
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions services/lobbies/k8s/lobbies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
value: "http://games:50051"
- name: HOST_PREFIX
value: "/api/lobbies"
- name: PLAYERS_HOST
value: "http://players"
- name: REDIS_HOST
value: "lobbies-redis-master"
- name: REDIS_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion services/lobbies/src/api/Services/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<Player> GetAsync(string playerId, CancellationToken cancellati
try
{
return await _client.GetFromJsonAsync<Player>(
$"http://players/{playerId}",
$"/{playerId}",
cancellationToken
);
}
Expand Down
23 changes: 13 additions & 10 deletions services/lobbies/src/api/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using lobbies.api.Hubs;
using lobbies.api.Models;
using lobbies.api.Repositories;
using lobbies.api.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using lobbies.api.Services;
using Microsoft.AspNetCore.Routing;
using lobbies.api.Repositories;
using lobbies.api.Models;
using lobbies.api.Hubs;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;

namespace lobbies.api
{
Expand Down Expand Up @@ -46,8 +46,11 @@ public void ConfigureServices(IServiceCollection services)
o.Address = Configuration.GetValue<Uri>("GAMES_HOST");
});
services.AddHealthChecks()
.AddRedis(GetRedisConnectionString(), tags: new string[]{"ready"});
services.AddHttpClient<PlayerService>();
.AddRedis(GetRedisConnectionString(), tags: new string[] { "ready" });
services.AddHttpClient<PlayerService>(c =>
{
c.BaseAddress = Configuration.GetValue<Uri>("PLAYERS_HOST");
});
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
Expand All @@ -72,7 +75,7 @@ public void Configure(IApplicationBuilder app)
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger(c =>
app.UseSwagger(c =>
{
c.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
{
Expand Down

0 comments on commit c2cf562

Please sign in to comment.