sdk

package
v0.0.0-...-daba113 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(parentCtx context.Context, options ...Option) error

Run starts uof connector.

Call to Run blocks until stopped by context, or error occurred. Order in which options are set is not important. Credentials and one of Callback or Pipe are functional minimum.

Types

type Config

type Config struct {
	CustomAMQPServer   string
	CustomAPIServer    string
	BookmakerID        int
	Token              string
	NodeID             int
	IsAMQPTLS          bool
	IsThrottled        bool
	PrefetchCount      int
	ConcurrentAPIFetch bool
	AutoAckDisabled    bool
	PipelineDisabled   bool
	Fixtures           time.Time
	Recovery           []uof.ProducerChange
	Stages             []pipe.InnerStage
	Replay             func(*api.ReplayAPI) error
	Env                uof.Environment
	Languages          []uof.Lang
	ErrorListener      ErrorListenerFunc
}

Config is active SDK configuration

type ErrorListenerFunc

type ErrorListenerFunc func(err error)

ErrorListenerFunc listens all SDK errors

type Option

type Option func(*Config)

Option sets attributes on the Config.

func BufferedConsumer

func BufferedConsumer(consumer pipe.ConsumerStage, buffer int) Option

BufferedConsumer same as consumer but with buffered `in` chan of size `buffer`.

func Callback

func Callback(cb func(m *uof.Message) error) Option

Callback sets handler for all messages.

If returns error will break the pipe and force exit from sdk.Run. Can be called multiple times.

func ConfigConcurrentAPIFetch

func ConfigConcurrentAPIFetch(concurrentAPIFetch bool) Option

ConfigConcurrentAPIFetch for auto-fetching rest api concurrently

func ConfigTLS

func ConfigTLS(isAMQPTLS bool) Option

ConfigTLS for setting tls flag

func ConfigThrottle

func ConfigThrottle(isThrottled bool, prefetchCount int) Option

ConfigThrottle is Throttled uses channel.Get internally. prefetchCount is to be used when isThrottled is false

func Consumer

func Consumer(consumer pipe.ConsumerStage) Option

Consumer sets chan consumer of the SDK messages stream.

Consumer should range over `in` chan and handle all messages. In chan will be closed on SDK tear down. If the consumer returns an error it is handled as fatal. Immediately closes SDK connection. Can be called multiple times.

func Credentials

func Credentials(bookmakerID int, token string, nodeID int) Option

Credentials for establishing connection to the uof queue and api.

func CustomServers

func CustomServers(customAMQPServer, customAPIServer string) Option

CustomServers for establishing custom servers

func DisableAutoAck

func DisableAutoAck() Option

DisableAutoAck requires usage of exposed message functions Ack/NackRequeue/NackDiscard

func DisablePipeline

func DisablePipeline() Option

DisablePipeline disables internal stages for processing markets, fixtures, players

func Fixtures

func Fixtures(to time.Time) Option

Fixtures gets live and pre-match fixtures at start-up.

It gets fixture for all matches which starts before `to` time. There is a special endpoint to get almost all fixtures before initiating recovery. This endpoint is designed to significantly reduce the number of API calls required during recovery.

Ref: https://docs.betradar.com/display/BD/UOF+-+Fixtures+in+the+API

func Global

func Global() Option

Global forces use of global production environment.

func Languages

func Languages(langs []uof.Lang) Option

Languages for api calls.

Statefull messages (markets, players, fixtures) will be served in all this languages. Each language requires separate call to api. If not specified `defaultLanguages` will be used.

func ListenErrors

func ListenErrors(listener ErrorListenerFunc) Option

ListenErrors sets ErrorListener for all SDK errors

func Recovery

func Recovery(pc []uof.ProducerChange) Option

Recovery starts recovery for each producer

It is responsibility of SDK consumer to track the last timestamp of the successfully consumed message for each producer. On startup this timestamp is sent here and SDK will request recovery; get all the messages after that ts.

Ref: https://docs.betradar.com/display/BD/UOF+-+Recovery+using+API

func Replay

func Replay(cb func(*api.ReplayAPI) error) Option

Replay forces use of replay environment. Callback will be called to start replay after establishing connection.

func Staging

func Staging() Option

Staging forces use of staging environment instead of production.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL