models

package
v0.0.0-...-163ab7f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExistQueue = errors.New("the queue already exist")
)

Error variables

Functions

This section is empty.

Types

type BenchmarkResult

type BenchmarkResult struct {
	Valid        bool `json:"valid"`
	RequestCount int  `json:"request_count"`
	ElapsedTime  int  `json:"elapsed_time"`
	Response     struct {
		Success     int `json:"success"`
		Redirect    int `json:"redirect"`
		ClientError int `json:"client_error"`
		ServerError int `json:"server_error"`
		Exception   int `json:"exception"`
	} `json:"response"`
	Violations []struct {
		RequestName string `json:"request_type"`
		Cause       string `json:"description"`
		Count       int    `json:"num"`
	} `json:"violations"`
}

BenchmarkResult represent the benchmark result JSON

type CurrentQueue

type CurrentQueue struct {
	ID     string `json:"message_id"`
	MyTeam bool   `json:"my_team"`
}

CurrentQueue represent current active queue

type Datastore

type Datastore struct {
	Conn *sql.DB
}

Datastore represent MySQL adapter

func NewDatastore

func NewDatastore() (*Datastore, error)

NewDatastore returns initialized Datastore

func (*Datastore) Close

func (d *Datastore) Close() error

Close calls DB.Close

type Queue

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

Queue is client for the pubsub

func NewQueue

func NewQueue(addr string) (*Queue, error)

NewQueue returns initialized Queue

func (*Queue) CurrentQueues

func (q *Queue) CurrentQueues(ctx context.Context, teamID int) ([]CurrentQueue, error)

CurrentQueues returns active current queues

func (*Queue) Publish

func (q *Queue) Publish(ctx context.Context, teamID int) (string, error)

Publish send queue message

func (*Queue) PullAndSave

func (q *Queue) PullAndSave(ctx context.Context) error

PullAndSave receive queue message and save message for Datastore

type QueueResponse

type QueueResponse struct {
	TeamID          int
	BenchmarkResult BenchmarkResult
	CreatedAt       time.Time
	SourceMessageID string
	Err             error
}

QueueResponse represent the message of the whole receive queue

type Score

type Score struct {
	ID          int       `json:"id"`
	Summary     string    `json:"summary"`
	Score       int       `json:"score"`
	Detail      string    `json:"detail"`
	SubmittedAt timeStamp `json:"submitted_at"`
}

Score represent benchmark score

func NewScore

func NewScore() *Score

NewScore returns initialized Score

func (*Score) Get

func (s *Score) Get(scoreID, teamID int) (*Score, error)

Get returns score object

func (*Score) History

func (s *Score) History(teamID int) ([]*Score, error)

History returns all team score

type Team

type Team struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Instance string `json:"instance"`
}

Team represent team configuration

func NewTeam

func NewTeam() *Team

NewTeam returns initialized Team object

func (*Team) Authentication

func (t *Team) Authentication(email, password string) (*Team, error)

Authentication returns Team when succeed authenticate

func (*Team) Get

func (t *Team) Get(id int) (*Team, error)

Get returns Team that assigned fields

func (*Team) Register

func (t *Team) Register(id int, name, email, password, instance string) error

Register register new team to the datastore

Jump to

Keyboard shortcuts

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