public TradeGenerator(TradeGeneratorConfiguration configuration, IEventStoreRepository <Guid> repository, IEventStoreCache <Guid, Trade> cache) { _configuration = configuration; _cache = cache; _repository = repository; _jwthandler = new JwtSecurityTokenHandler(); _cleanup = new CompositeDisposable(); var settings = AppCore.Instance.Get <JsonSerializerSettings>(); var refitSettings = new RefitSettings() { ContentSerializer = new JsonContentSerializer(settings), HttpMessageHandlerFactory = () => new HttpRetryForeverMessageHandler(5000) }; var accessTokenRetrieverFactory = new AccessTokenRetrieverFactory(); _tradeService = ApiServiceBuilder <ITradeService> .Build(configuration.Gateway) .AddAuthorizationHeader(accessTokenRetrieverFactory.GetToken( "bob.woodworth", "bob", _configuration.Identity, AzurePlaygroundConstants.Auth.ClientReferenceToken, AzurePlaygroundConstants.Api.Trade, _configuration.Key )) .Create(refitSettings: refitSettings); }
public PricePublisher(IPriceService priceService, PriceServiceConfiguration configuration) { _rand = new Random(); _priceService = priceService; _configuration = configuration; var accessTokenRetrieverFactory = new AccessTokenRetrieverFactory(); var tokenRetriever = accessTokenRetrieverFactory.GetToken( "internal", "idkfa", _configuration.Identity, AzurePlaygroundConstants.Auth.ClientReferenceToken, AzurePlaygroundConstants.Api.Trade, _configuration.Key ); _priceHubService = SignalRServiceBuilder <Price, PriceRequest> .Create() .Build(new PriceRequest((p) => true), (opts) => { opts.AccessTokenProvider = () => Task.FromResult(tokenRetriever()); }); _priceHubService.Connect(Scheduler.Default, 2000); _cleanUp = new CompositeDisposable(); }
public TradeEventListener(TradeEventServiceConfiguration configuration, IEventStoreCache <Guid, Trade> cache) { _cache = cache; var accessTokenRetrieverFactory = new AccessTokenRetrieverFactory(); var tokenRetriever = accessTokenRetrieverFactory.GetToken( "internal", "idkfa", configuration.Identity, AzurePlaygroundConstants.Auth.ClientReferenceToken, AzurePlaygroundConstants.Api.Trade, configuration.Key ); _tradeEventHubService = SignalRServiceBuilder <Trade, TradeEventRequest> .Create() .Build(new TradeEventRequest((p) => true), (opts) => { opts.AccessTokenProvider = () => Task.FromResult(tokenRetriever()); }); _tradeEventHubService.Connect(Scheduler.Default, 2000); }