sdk

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 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(ctx 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 {
	BookmakerID   string
	Token         string
	Fixtures      time.Time
	Recovery      []uof.ProducerChange
	Stages        []pipe.InnerStage
	Replay        func(*api.ReplayAPI) error
	Env           uof.Environment
	Staging       bool
	BindVirtuals  bool
	BindSports    bool
	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 BindSports

func BindSports() Option

BindSports bind only to sports messages

func BindVirtuals

func BindVirtuals() Option

BindVirtuals bind only to virtuals messages

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 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, token string) Option

Credentials for establishing connection to the uof queue and api.

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