Commit f826d4c2 authored by Sondre Bjellås's avatar Sondre Bjellås

Add TickerSettings to allow configuration of different tickers.

Moved the key for Sentry into configuration file, configuration format for Sentry coming in a future commit.
parent 946bfcc9
...@@ -20,7 +20,7 @@ namespace Stratis.Guru ...@@ -20,7 +20,7 @@ namespace Stratis.Guru
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args) WebHost.CreateDefaultBuilder(args)
.UseUrls("http://localhost:1989") .UseUrls("http://localhost:1989")
.UseSentry("https://ed8ea72e1f6341ae901d96691d9e58a0@sentry.io/1359208") .UseSentry()
.UseStartup<Startup>(); .UseStartup<Startup>();
} }
} }
\ No newline at end of file
...@@ -18,14 +18,16 @@ namespace Stratis.Guru.Services ...@@ -18,14 +18,16 @@ namespace Stratis.Guru.Services
private readonly UpdateHub _hub; private readonly UpdateHub _hub;
private readonly System.Timers.Timer _updateTimer; private readonly System.Timers.Timer _updateTimer;
private readonly NakoApiSettings _nakoApiSettings; private readonly NakoApiSettings _nakoApiSettings;
private readonly TickerSettings _tickerSettings;
public UpdateInfosService(IMemoryCache memoryCache, UpdateHub hub, IHubContext<UpdateHub> hubContext, IOptions<NakoApiSettings> nakoApiSettings) public UpdateInfosService(IMemoryCache memoryCache, UpdateHub hub, IHubContext<UpdateHub> hubContext, IOptions<NakoApiSettings> nakoApiSettings, IOptions<TickerSettings> tickerSettings)
{ {
_memoryCache = memoryCache; _memoryCache = memoryCache;
_hub = hub; _hub = hub;
_hubContext = hubContext; _hubContext = hubContext;
_updateTimer = new System.Timers.Timer(); _updateTimer = new System.Timers.Timer();
_nakoApiSettings = nakoApiSettings.Value; _nakoApiSettings = nakoApiSettings.Value;
_tickerSettings = tickerSettings.Value;
} }
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
...@@ -35,7 +37,7 @@ namespace Stratis.Guru.Services ...@@ -35,7 +37,7 @@ namespace Stratis.Guru.Services
_updateTimer.Elapsed += async (sender, args) => _updateTimer.Elapsed += async (sender, args) =>
{ {
_updateTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds; _updateTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds;
var coinmarketCapApiClient = new RestClient("https://api.coinmarketcap.com/v2/ticker/1343/"); var coinmarketCapApiClient = new RestClient(_tickerSettings.ApiUrl);
var coinmarketCapApiRequest = new RestRequest(Method.GET); var coinmarketCapApiRequest = new RestRequest(Method.GET);
var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest); var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest);
_memoryCache.Set("Coinmarketcap", coinmarketcapApi.Content); _memoryCache.Set("Coinmarketcap", coinmarketcapApi.Content);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Stratis.Guru.Settings
{
public class TickerSettings
{
public string ApiUrl { get; set; }
}
}
...@@ -52,6 +52,7 @@ namespace Stratis.Guru ...@@ -52,6 +52,7 @@ namespace Stratis.Guru
services.Configure<NakoApiSettings>(Configuration.GetSection("NakoApi")); services.Configure<NakoApiSettings>(Configuration.GetSection("NakoApi"));
services.Configure<FixerApiSettings>(Configuration.GetSection("FixerApi")); services.Configure<FixerApiSettings>(Configuration.GetSection("FixerApi"));
services.Configure<DrawSettings>(Configuration.GetSection("Draw")); services.Configure<DrawSettings>(Configuration.GetSection("Draw"));
services.Configure<TickerSettings>(Configuration.GetSection("Ticker"));
services.AddMemoryCache(); services.AddMemoryCache();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment