gomeetupbris

package module
v0.0.0-...-3cb1490 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

README

Go Meetup Brisbane, May 2019

Go Report Card

To Run

go get github.com/brettniven/gomeetupbris

Then in that dir:

go test ./... -cover (or better still - run the tests from an IDE that allows you to see the coverage (such as IntelliJ, VSCode))

Notes

  • This repo has been copied from a private project of mine and package names altered accordingly
  • This has been published to show the test pattern described in the session which was basically:
    • Focus on testing the service as opposed to the internal algorithms. Services are smaller these days. See the service as your 'unit'.
    • These tests are typically in the form of input, someExternalCall(s), output. Using dir/file based approaches make this very clean
    • The service_test tests most cases, with minimal effort. This alone results in > 85% coverage
    • Other tests can then be created to fill coverage gaps, where the tests are meaningful. In this case, pipeline_test covers error conditions that service_test wasn't granular enough for
  • This repo can also be a reference point for useful libraries, code quality tools, a microservice template, and a reference point for a data pipeline approach using channels
  • It will be of no use as an actual service, as to run, it requires a grpc server and appropriate runtime config
  • I've committed the vendor dir as some lib dependencies would otherwise be non-go-gettable as they live in private repos

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Delta = modelops.Delta

Delta is an indirection of the Merge func, making it simple to mock them in tests

View Source
var Merge = modelops.Merge

Merge is an indirection of the Merge func, making it simple to mock them in tests

Functions

func NewHandler

func NewHandler() http.Handler

NewHandler creates the http handler

Types

type BetEasyAgentService

type BetEasyAgentService struct {
	// contains filtered or unexported fields
}

BetEasyAgentService models the agent

func NewService

func NewService(agentGatewayClient api.AgentGatewayClient, liveSportsEndpoint string, pollInterval time.Duration, deltasOnly bool) *BetEasyAgentService

NewService creates a new servicez

func (*BetEasyAgentService) Start

func (svc *BetEasyAgentService) Start()

Start starts the agent

func (*BetEasyAgentService) Stop

func (svc *BetEasyAgentService) Stop()

Stop stops the agent

type EventType

type EventType struct {
	EventTypeDesc string          `json:"EventTypeDesc"` // e.g. Basketball
	EventTypeSlug string          `json:"EventTypeSlug"` // e.g. basketball
	Events        []ProviderEvent `json:"Events"`
}

EventType models a sport

type FeaturedMarket

type FeaturedMarket struct {
	EventID             int64     `json:"EventID"`
	EventName           string    `json:"EventName"`           // e.g. Head to Head
	AdvertisedStartTime time.Time `json:"AdvertisedStartTime"` // e.g 2019-02-14T08:50:00Z
	IsOpenForBetting    bool      `json:"IsOpenForBetting"`
	Outcomes            []Outcome `json:"Outcomes"`
}

FeaturedMarket models the main market

type LiveEndpointResponse

type LiveEndpointResponse struct {
	EventTypes []EventType `json:"EventTypes"`
}

LiveEndpointResponse models the provider response

type Outcome

type Outcome struct {
	FixedMarketID int64   `json:"FixedMarketID"` // this seems to be unique per selection
	OutcomeID     int64   `json:"OutcomeID"`     // this is unique within the market. i.e. 1/2/3 for teamA, draw, teamB
	OutcomeName   string  `json:"OutcomeName"`   // selection name
	Price         float64 `json:"Price"`         // decimal price
}

Outcome models a selection

type ProviderEvent

type ProviderEvent struct {
	MasterEventID             int64          `json:"MasterEventID"`
	MasterEventName           string         `json:"MasterEventName"`           // e.g. Melbourne United v Cairns Taipans
	DisplayMasterCategoryName string         `json:"DisplayMasterCategoryName"` // e.g NBL
	FeaturedMarket            FeaturedMarket `json:"FeaturedMarket"`
	Sport                     string         // not json, populated when iterating
}

ProviderEvent models the provider event

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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