Documentation
¶
Index ¶
- type Action
- type Client
- type Config
- type ConnectionStatus
- type EntitiesStreamStatus
- type Event
- type EventEnvelope
- type EventPoints
- type EventSettlement
- type EventSettlementEnvelope
- type EventStatus
- type EventTimer
- type Market
- type MarketEnvelope
- type MarketParam
- type MarketParamType
- type MarketType
- type Outcome
- type OutcomeSettlementStatus
- type OutcomeType
- type Period
- type PointType
- type PointsGroup
- type Session
- type SportDescription
- type StateEntry
- type TimerState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action int32
Action defines operation which shall be done on entity: InsertAction, UpdateAction, DeleteAction
const ( // UnknownAction action shall not be received from x-feed, in case of receiving this value UnknownAction Action = 0 // InsertAction action indicates that brand new entity is received InsertAction Action = 1 // DeleteAction action indicates that x-feed is not going to keep sending updates for specific entity DeleteAction Action = 2 // UpdateAction action indicates that update for existent entity was received UpdateAction Action = 3 )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents X-feed client
func NewClient ¶
NewClient provides casual way for creating the Client instance
type Config ¶
type Config struct {
ClientID string
// grpc transport specific parameters
ServerURI string
// DialTimeout is the timeout for failing to establish a connection.
DialTimeout time.Duration
RequestDeadline time.Duration
RequestRateLimit float64
RequestRateLimitBurst int
EntitiesRefreshInterval time.Duration
MaxMessageSize int
// After a duration of this time if the client doesn't see any activity
// it pings the server to see if the transport is still alive.
// it is better to set it no more than 1 sec?
InactiveTimeout time.Duration
// After having pinged for keepalive check,
// the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.
KeepAliveTimeout time.Duration // The current default value is 20 seconds.
// If true, client runs keepalive checks even with no active RPCs.
PermitWithoutStream bool // false by default.
//StatusChangeHandler stores function which is invoked any time when status is changed
// that function accepts instance of ConnectionStatus struct instance
StatusChangeHandler func(ConnectionStatus)
}
Config represents configuration of x-feed Client
type ConnectionStatus ¶
type ConnectionStatus struct {
EventsStreamStatus EntitiesStreamStatus
SettlementsStream EntitiesStreamStatus
}
ConnectionStatus aggregates statuses of StreamEvents and StreamSettlements grpc endpoints
type EntitiesStreamStatus ¶
type EntitiesStreamStatus int
EntitiesStreamStatus type represents current xfeed entities stream state
const ( // StatusGreen means connection is Ok bets can be accepted StatusGreen EntitiesStreamStatus = iota + 1 // StatusYellow means that recovery is in a progress we can't accept bets StatusYellow // StatusRed means something is wrong we can't accept bets StatusRed )
type Event ¶
type Event struct {
ID string
SportID int32
Category string
League string
Status EventStatus
Start *time.Time
Participants []string
Timer *EventTimer
Statistics *EventPoints
}
Event represents Sport event (game) within specific sport/category/league
type EventEnvelope ¶
EventEnvelope represents state update of specific Event
type EventPoints ¶
type EventPoints struct {
PointGroups []*PointsGroup
}
EventPoints represents live game resulting or final game statistics
type EventSettlement ¶
type EventSettlement struct {
EventID string
Resulting *EventPoints
Outcomes map[string]OutcomeSettlementStatus
}
EventSettlement contains settlements for Outcomes for specific event
type EventSettlementEnvelope ¶
type EventSettlementEnvelope struct {
EventSettlement *EventSettlement
GeneratedAt *time.Time
}
EventSettlementEnvelope represents state update of specific EventSettlement
type EventStatus ¶
type EventStatus int32
EventStatus represents state of event, prematch or live
const ( // EventStatusUnknown shall not be received EventStatusUnknown EventStatus = 0 // EventStatusPrematch indicates that match is in prematch EventStatusPrematch EventStatus = 1 // EventStatusLive indicates that match is in live EventStatusLive EventStatus = 2 )
type EventTimer ¶
type EventTimer struct {
Changed *time.Time
Time *time.Duration
State TimerState
}
EventTimer represents game timer. For some Sports time direction is counterclockwise (for example for basketball)
type Market ¶
type Market struct {
ID string
MarketTypeID int32
MarketParams []*MarketParam
Outcomes []*Outcome
}
Market represents market instance
type MarketEnvelope ¶
type MarketEnvelope struct {
EventID string
MarketDiff *Market
GeneratedAt *time.Time
Action Action
}
MarketEnvelope represents state update of specific Market
type MarketParam ¶
type MarketParam struct {
Type MarketParamType
Value string
}
MarketParam is key value for specific market parameter (for parametrized markets)
type MarketParamType ¶
type MarketParamType int32
MarketParamType represents type of parameter of parametrised market
const ( // MarketParamTypeUnknown shall not be used MarketParamTypeUnknown MarketParamType = 0 // MarketParamTypePeriod represents market parameter which reflects period of the game MarketParamTypePeriod MarketParamType = 1 // MarketParamTypeTotal represents market parameter which reflects total count MarketParamTypeTotal MarketParamType = 2 // MarketParamTypeHandicap represents market parameter which reflects fora for teams MarketParamTypeHandicap MarketParamType = 3 // MarketParamTypeTeam epresents market parameter which reflects competitor team order number MarketParamTypeTeam MarketParamType = 4 )
type MarketType ¶
type MarketType struct {
ID int32
// event.participants = ["Dinamo", "Shakhtar"]
// market_params.team = 1
// Ex.: "{%participant} Total" -> "Dinamo Total"
NameTemplate string
OutcomeTypes []*OutcomeType
}
MarketType contains template for the Market name Variables: "{%participant}" - get participant name by number in market_param "team" (1, 2) "{$participantN}" - participant by predefined number. "{+$handicap}", "{-$handicap}" - market_param "handicap" "{$total}" - market_param "total"
type Outcome ¶
Outcome represents specific instance of outcome
type OutcomeSettlementStatus ¶
type OutcomeSettlementStatus int32
OutcomeSettlementStatus represents result status of outcome: unsettled, win, lose, return
const ( // OutcomeSettlementUnknown shall not be used OutcomeSettlementUnknown OutcomeSettlementStatus = 0 OutcomeSettlementUnsettled OutcomeSettlementStatus = 1 OutcomeSettlementWin OutcomeSettlementStatus = 2 OutcomeSettlementLose OutcomeSettlementStatus = 3 OutcomeSettlementReturn OutcomeSettlementStatus = 4 )
type OutcomeType ¶
type OutcomeType struct {
ID int32
// event.participants = ["Dinamo", "Shakhtar"]
// market_params.handicap = 1.5
// Ex.: "{$participant2} ({-$handicap})" -> "Shakhtar (-1.5)"
NameTemplate string
}
OutcomeType contains template for the Outcome name
type Period ¶
Period represents Sport specific timespan of the game, e. g. full time, first half, set, etc.
type PointType ¶
type PointType int32
PointType represents type of statistics unit: Score, Red cards, Corners, etc.
const ( // PointTypeUnknown shall not be used as type of points, if x-feed sends this, it means something went wrong PointTypeUnknown PointType = 0 // PointTypeScore represents game score PointTypeScore PointType = 1 // PointTypeRedСards represents Red Cards PointTypeRedСards PointType = 2 // PointTypeYellowСards represents yellow cards PointTypeYellowСards PointType = 3 // PointTypePenalties represents penalties PointTypePenalties PointType = 4 // PointTypeCorners represents corners PointTypeCorners PointType = 5 )
type PointsGroup ¶
type PointsGroup struct {
PointType PointType
GroupPeriodID int32
State []*StateEntry
}
PointsGroup represents statistics unit of specific type for specific game period
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents started and working session of x-feed.
func (*Session) Entities ¶
func (s *Session) Entities(language string) ([]*SportDescription, error)
Entities returns current snapshot of SportDescriptions. when there is communication errors with X-feed servers error is returned
func (*Session) EventsFeed ¶
func (s *Session) EventsFeed() (<-chan *EventEnvelope, <-chan *MarketEnvelope, error)
EventsFeed returns channels of state updates for Events and Markets. when there are communication errors with X-feed servers it closes the channels
func (*Session) SettlementsFeed ¶
func (s *Session) SettlementsFeed(lastConsumed time.Time) (<-chan *EventSettlementEnvelope, error)
SettlementsFeed returns channel of state updates for event settlements from specific point of time. when there is communication errors with X-feed servers it closes the channels
type SportDescription ¶
type SportDescription struct {
ID int32
Language string
Name string
Periods []*Period
MarketTypes []*MarketType
}
SportDescription is sent for each sport which x-feed supports. It contains list of Periods and MarketTypes which are used for specific sport
type StateEntry ¶
StateEntry represents statistics entry for specific participant
type TimerState ¶
type TimerState int32
TimerState represents state of the timer: paused, forward, Backward
const ( // TimerStateUnknown shall not be received, it indicates that something is wrong on x-feed side TimerStateUnknown TimerState = 0 // TimerStateForward indicates that timer need to increase it's value TimerStateForward TimerState = 1 // TimerStateBackward indicates that timer need to decrease it's value TimerStateBackward TimerState = 2 // TimerStatePause indicates that timer is paused TimerStatePause TimerState = 3 )
Source Files
¶
- client.go
- config.go
- model.go
- session.go
Directories
¶
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
xfeed_proto
Package xfeed_proto contains all proto files while sdk in alpha in future all proto files will be moved to separate repository nolint:golint
|
Package xfeed_proto contains all proto files while sdk in alpha in future all proto files will be moved to separate repository nolint:golint |