public GTPService(ISettings settings = null) { _settings = settings ?? Settings.Instance; _logger = LogManager.GetLogger(typeof(GTPService).ToString()); _sportsList = new List <string> { "Tennis" }; _listeners = new ConcurrentDictionary <string, StreamListener>(); _activeFixtures = new ConcurrentDictionary <string, bool>(); UDAPI.SdkActroSystemInit(); }
/// <summary> /// Allows to stop the adapter. /// /// Before returning, and if it is so configured, /// the adapter sends a "suspend" request to /// all the currently registred fixtures. /// </summary> public void Stop() { _logger.InfoFormat("Adapter is stopping"); try { _platformConnector?.Dispose(); _udapiServiceFacade?.Disconnect(); AdapterActorSystem.Dispose(); UDAPI.Dispose(); } catch (Exception e) { _logger.Error("An error occured while disposing the adapter", e); } _stats.SetValue(AdapterCoreKeys.ADAPTER_STARTED, "0"); _logger.InfoFormat("Adapter stopped"); }
/// <summary> /// Starts the adapter. /// This method returns immediately leaving to a background worker /// the task of getting the data and process it. /// /// Throws an exception if it can't initialise itself. /// </summary> public void Start() { try { LogVersions(); if (SdkActorSystem.InitializeActors) { _logger.Info("SDK is restarting..."); UDAPI.Init(new UdapiConfiguration(_settings)); } _logger.Info("Adapter is connecting to the UDAPI service..."); _udapiServiceFacade.Connect(); if (!_udapiServiceFacade.IsConnected) { return; } _logger.Debug("Adapter connected to the UDAPI - initialising..."); AdapterActorSystem.Init( _settings, _udapiServiceFacade, _platformConnector, _stateManager, _suspensionManager, _streamHealthCheckValidation, _fixtureValidation); _logger.InfoFormat("Adapter started"); _stats.SetValue(AdapterCoreKeys.ADAPTER_STARTED, "1"); } catch (Exception ex) { _logger.Fatal("A fatal error has occurred and the Adapater cannot start. You can try a manual restart", ex); throw; } }
public Adapter( ISettings settings, IServiceFacade udapiServiceFacade, IAdapterPlugin platformConnector, IStateManager stateManager, IStateProvider stateProvider, ISuspensionManager suspensionManager, IStreamHealthCheckValidation streamHealthCheckValidation, IFixtureValidation fixtureValidation) { _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _udapiServiceFacade = udapiServiceFacade ?? throw new ArgumentNullException(nameof(udapiServiceFacade)); _platformConnector = platformConnector ?? throw new ArgumentNullException(nameof(platformConnector)); _stateManager = stateManager ?? throw new ArgumentNullException(nameof(stateManager)); _suspensionManager = suspensionManager ?? throw new ArgumentNullException(nameof(suspensionManager)); _streamHealthCheckValidation = streamHealthCheckValidation ?? throw new ArgumentNullException(nameof(streamHealthCheckValidation)); _fixtureValidation = fixtureValidation ?? throw new ArgumentNullException(nameof(fixtureValidation)); UDAPI.Init(new UdapiConfiguration(_settings)); StateProviderProxy.Init(stateProvider); if (settings.StatsEnabled) { StatsManager.Configure(); } platformConnector.Initialise(); stateManager.AddRules(platformConnector.MarketRules); ThreadPool.SetMinThreads(500, 500); _stats = StatsManager.Instance["adapter.core"].GetHandle(); PopuplateAdapterVersionInfo(); }