sportradar / UnifiedOddsSdkNetCore

UnifiedFeed SDK is a client library that enables easier integration with the Betradar XML feeds. SDK exposes XML feed service interface in a more user-friendly way and isolates the client from having to do XML feed parsing, proper connection handling, error recovery, event queuing, data caching and dispatching.
https://sportradar.github.io/UnifiedOddsSdkNetCore/
Other
17 stars 14 forks source link

Extend configuration [WIP] #15

Closed 0UserName closed 3 years ago

0UserName commented 3 years ago

Description

Migrating SDK configuration to Microsoft.Extensions.Configuration.* libraries. This gives:

Added the ability to replace endpoints related to the Integration API,Recovery API via config file, the original endpoints are saved as default. This gives:

An example of a new configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <configSections>
    <section name="oddsFeedSection" type="Sportradar.OddsFeed.SDK.API.Internal.OddsFeedConfigurationSection, Sportradar.OddsFeed.SDK" />
  </configSections>

  <!--  

   Required attributes:    
   accessToken - the access token used for the authentication to the broker and to the sports api

   Optional attributes:
   inactivitySeconds - sets the max time window between two messages before the producer is market as "down" (between 20 and 180 seconds; default: 20)
   host - sets the URL of the messaging host (broker) (mq.betradar.com)
   virtualHost - sets the name of the virtual host configured on the messaging server (broker)
   exchange - sets the exchange to which queues are bound on the messaging server (broker)
   apiHost - sets the URL of the API host (https://api.betradar.com)
   useSSL - sets the value indicating whether a secure connection to the message broker should be used (true or false)
   supportedLanguages - sets the comma delimited string of all languages (en,de,nl)
   useIntegrationEnvironment - sets a value indicating whether the unified feed integration environment should be used (true or false)
   exceptionHandlingStrategy - sets a ExceptionHandlingStrategy enum member specifying how to handle exceptions thrown to outside callers (ExceptionHandlingStrategy.CATCH or ExceptionHandlingStrategy.THROW)
   disabledProducers - sets the comma delimited list of ids of disabled producers (1,2,7,9)
   maxRecoveryTime - sets the timeout for recovery to finish (minimum 900 sec)
   nodeId - sets the node id for this instance of the sdk (recommended when running multiple instances). MTS customer must set this value! Use only positive numbers; negative are reserved for internal use.
   adjustAfterAge - gets the indication whether the after age should be adjusted before executing recovery request
   httpClientTimeout - sets the timeout for HTTP responses used to fetch data from API (between 10 and 100 seconds; default: 30)
   recoveryHttpClientTimeout - sets the timeout for recovery HTTP responses used to fetch data from API (between 10 and 100 seconds; default: 30)

 -->
  <oddsFeedSection accessToken="accessToken" apiHost="apiHost" host="host" port="port" virtualhost="virtualhost" exchange="exchange" username="username" defaultLanguage="en" nodeId="1">
    <endpoints>
      <!-- Bookmaker -->
      <BookmakerDetailsProvider baseUrl="{0}/v1/users/whoami" />
      <NonMappingDataProvider   baseUrl="/v1/descriptions/producers" />

      <!-- Sport data -->
      <competitorProfileProvider   baseUrl="/v1/sports/{1}/competitors/{0}/profile" />
      <fixtureEndpointDataProvider baseUrl="/v1/sports/{1}/sport_events/{0}/fixture" ReplayUrl="/sports/{1}/sport_events/{0}/fixture" />
      <fixtureChangesProvider      baseUrl="/v1/sports/{0}/fixtures/changes" />
      <sportEventSummaryProvider   baseUrl="/v1/sports/{1}/sport_events/{0}/summary" />
      <dateScheduleProvider        baseUrl="/v1/sports/{1}/schedules/{0}/schedule" />
      <allSportsProvider           baseUrl="/v1/sports/{0}/sports" />

      <!-- Descriptions -->
      <MatchStatusDataProvider             baseUrl="/v1/descriptions/{0}/match_status" />
      <invariantMarketDescriptionsProvider baseUrl="/v1/descriptions/{0}/markets" />

      <!-- Tournaments -->
      <allTournamentsProvider     baseUrl="/v1/sports/{0}/tournaments" />
      <availableSportTournaments  baseUrl="/v1/sports/{0}/sports/{1}/tournaments" />
      <tournamentScheduleProvider baseUrl="/v1/sports/{1}/tournaments/{0}/schedule" />

      <!-- Recovery -->
      <afterTimestampRecovery        baseUrl="{0}/recovery/initiate_request?after={1}&amp;request_id={2}" />
      <fullOddsRecovery              baseUrl="{0}/recovery/initiate_request?request_id={1}" />
      <eventMessagesRecovery         baseUrl="{0}/odds/events/{1}/initiate_request" />
      <eventStatefulMessagesRecovery baseUrl="{0}/stateful_messages/events/{1}/initiate_request" />
    </endpoints>
  </oddsFeedSection>
</configuration>

Type of change

How Has This Been Tested?

Partial testing using new configuration options:


Checklist:


Remarks

This PR is currently aimed at obtaining feedback on both the implementation and the very possibility of their merging into upstream. If the introduction of such changes is not intended, then there is probably no point in this PR.