model

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// StatusOK means the latest run in test was within the threshold
	StatusOK = Status("ok")

	// StatusFail means the latest run in test was not within the threshold
	StatusFail = Status("fail")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketList

type BucketList []*runner.Bucket

BucketList is a slice of buckets

func (*BucketList) Scan

func (bl *BucketList) Scan(src interface{}) error

Scan converts database value to a struct

func (BucketList) Value

func (bl BucketList) Value() (driver.Value, error)

Value converts struct to a database value

type Detail

type Detail struct {
	Model

	Report *Report `json:"-"`

	// Run id
	ReportID uint `json:"reportID" gorm:"type:integer REFERENCES reports(id) ON DELETE CASCADE;not null"`

	runner.ResultDetail
}

Detail represents a report detail

func (*Detail) BeforeSave

func (d *Detail) BeforeSave() error

BeforeSave is called by GORM before save

func (*Detail) UnmarshalJSON

func (d *Detail) UnmarshalJSON(data []byte) error

UnmarshalJSON for Detail

type Histogram

type Histogram struct {
	Model

	ReportID uint    `json:"reportID" gorm:"type:integer REFERENCES reports(id) ON DELETE CASCADE;not null"`
	Report   *Report `json:"-"`

	Buckets BucketList `json:"buckets" gorm:"type:TEXT"`
}

Histogram represents a histogram

func (*Histogram) BeforeSave

func (h *Histogram) BeforeSave(scope *gorm.Scope) error

BeforeSave is called by GORM before save

type LatencyDistributionList

type LatencyDistributionList []*runner.LatencyDistribution

LatencyDistributionList is a slice of LatencyDistribution pointers

func (*LatencyDistributionList) Scan

func (ld *LatencyDistributionList) Scan(src interface{}) error

Scan converts database value to a struct

func (LatencyDistributionList) Value

func (ld LatencyDistributionList) Value() (driver.Value, error)

Value converts struct to a database value

type Model

type Model struct {
	// The id
	ID uint `json:"id" gorm:"primary_key"`

	// The creation time
	CreatedAt time.Time `json:"createdAt"`

	// The updated time
	UpdatedAt time.Time `json:"updatedAt"`
}

Model base model definition. Copy of gorm.Model with custom tags

type Options

type Options struct {
	Model

	Report *Report `json:"-"`

	// Run id
	ReportID uint `json:"reportID" gorm:"type:integer REFERENCES reports(id) ON DELETE CASCADE;not null"`

	Info *OptionsInfo `json:"info,omitempty" gorm:"type:TEXT"`
}

Options represents a report detail

func (*Options) BeforeSave

func (o *Options) BeforeSave(scope *gorm.Scope) error

BeforeSave is called by GORM before save

type OptionsInfo

type OptionsInfo runner.Options

OptionsInfo represents the report options

func (*OptionsInfo) Scan

func (o *OptionsInfo) Scan(src interface{}) error

Scan converts database value to an Options struct

func (OptionsInfo) Value

func (o OptionsInfo) Value() (driver.Value, error)

Value converts options struct to a database value

type Project

type Project struct {
	Model
	Name        string `json:"name" gorm:"not null"`
	Description string `json:"description"`
	Status      Status `json:"status" gorm:"not null"`
}

Project represents a project

func (*Project) BeforeCreate

func (p *Project) BeforeCreate() error

BeforeCreate is a GORM hook called when a model is created

func (*Project) BeforeSave

func (p *Project) BeforeSave() error

BeforeSave is a GORM hook called when a model is created or updated

func (*Project) BeforeUpdate

func (p *Project) BeforeUpdate() error

BeforeUpdate is a GORM hook called when a model is updated

type Report

type Report struct {
	Model

	ProjectID uint     `json:"projectID" gorm:"type:integer REFERENCES projects(id) ON DELETE CASCADE;not null"`
	Project   *Project `json:"-"`

	Name      string    `json:"name,omitempty"`
	EndReason string    `json:"endReason,omitempty"`
	Date      time.Time `json:"date"`

	Count   uint64        `json:"count"`
	Total   time.Duration `json:"total"`
	Average time.Duration `json:"average"`
	Fastest time.Duration `json:"fastest"`
	Slowest time.Duration `json:"slowest"`
	Rps     float64       `json:"rps"`

	Status Status `json:"status" gorm:"not null"`

	ErrorDist      StringIntMap `json:"errorDistribution,omitempty" gorm:"type:TEXT"`
	StatusCodeDist StringIntMap `json:"statusCodeDistribution,omitempty" gorm:"type:TEXT"`

	LatencyDistribution LatencyDistributionList `json:"latencyDistribution" gorm:"type:TEXT"`

	Tags StringStringMap `json:"tags,omitempty" gorm:"type:TEXT"`
}

Report represents a project

func (*Report) BeforeSave

func (r *Report) BeforeSave() error

BeforeSave is called by GORM before save

type Status

type Status string

Status represents a status of a project or record

func StatusFromString

func StatusFromString(str string) Status

StatusFromString creates a Status from a string

type StringIntMap

type StringIntMap map[string]int

StringIntMap is a map of string keys to int values

func (*StringIntMap) Scan

func (m *StringIntMap) Scan(src interface{}) error

Scan converts database value to a map

func (StringIntMap) Value

func (m StringIntMap) Value() (driver.Value, error)

Value converts map to database value

type StringStringMap

type StringStringMap map[string]string

StringStringMap is a map of string keys to int values

func (*StringStringMap) Scan

func (m *StringStringMap) Scan(src interface{}) error

Scan converts database value to a map

func (StringStringMap) Value

func (m StringStringMap) Value() (driver.Value, error)

Value converts map to database value

Jump to

Keyboard shortcuts

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