Documentation ¶
Index ¶
- Constants
- type Bucket
- type Detail
- type DetailService
- func (ds *DetailService) Count(rid uint) (uint, error)
- func (ds *DetailService) Create(r *Detail) error
- func (ds *DetailService) CreateBatch(rid uint, s []*Detail) (uint, uint)
- func (ds *DetailService) Delete(r *Detail) error
- func (ds *DetailService) DeleteAll(rid uint) error
- func (ds *DetailService) FindByID(id uint) (*Detail, error)
- func (ds *DetailService) FindByRunID(rid, num, page uint) ([]*Detail, error)
- func (ds *DetailService) FindByRunIDAll(rid uint) ([]*Detail, error)
- func (ds *DetailService) FindByRunIDSorted(rid, num, page uint, sortField, order string) ([]*Detail, error)
- func (ds *DetailService) Update(d *Detail) error
- type LatencyDistribution
- type Model
- type Options
- type Project
- type ProjectService
- func (ps *ProjectService) Count() (uint, error)
- func (ps *ProjectService) Create(p *Project) error
- func (ps *ProjectService) Delete(p *Project) error
- func (ps *ProjectService) FindByID(id uint) (*Project, error)
- func (ps *ProjectService) FindByName(name string) (*Project, error)
- func (ps *ProjectService) List(limit, page uint) ([]*Project, error)
- func (ps *ProjectService) ListSorted(limit, page uint, sortField, order string) ([]*Project, error)
- func (ps *ProjectService) Update(p *Project) error
- type Run
- type RunService
- func (rs *RunService) Count(tid uint) (uint, error)
- func (rs *RunService) Create(r *Run) error
- func (rs *RunService) Delete(r *Run) error
- func (rs *RunService) FindByID(id uint) (*Run, error)
- func (rs *RunService) FindByTestID(tid, num, page uint, populate bool) ([]*Run, error)
- func (rs *RunService) FindByTestIDSorted(tid, num, page uint, sortField, order string, histogram bool, latency bool) ([]*Run, error)
- func (rs *RunService) FindLatest(tid uint) (*Run, error)
- func (rs *RunService) Update(r *Run) error
- type Status
- type Test
- func (t *Test) AfterFind() error
- func (t *Test) AfterSave() error
- func (t *Test) BeforeCreate() error
- func (t *Test) BeforeSave(scope *gorm.Scope) error
- func (t *Test) BeforeUpdate() error
- func (t *Test) SetStatus(tMean, tMedian, t95, fastest, slowest time.Duration, rps float64, ...)
- func (t *Test) UnmarshalJSON(data []byte) error
- type TestService
- func (ts *TestService) Count(pid uint) (uint, error)
- func (ts *TestService) Create(t *Test) error
- func (ts *TestService) Delete(t *Test) error
- func (ts *TestService) FindByID(id uint) (*Test, error)
- func (ts *TestService) FindByName(pid uint, name string) (*Test, error)
- func (ts *TestService) FindByProjectID(pid, num, page uint) ([]*Test, error)
- func (ts *TestService) FindByProjectIDSorted(pid, num, page uint, sortField, order string) ([]*Test, error)
- func (ts *TestService) Update(t *Test) error
- type Threshold
- type ThresholdSetting
Constants ¶
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") )
const ( // ThresholdMean is the threshold for mean / average ThresholdMean Threshold = Threshold("mean") // ThresholdMedian is the threshold for the median ThresholdMedian = Threshold("median") // Threshold95th is the threshold for the 95th percentile Threshold95th = Threshold("95th") // ThresholdFastest is the threshold for the fastest metric ThresholdFastest = Threshold("fastest") // ThresholdSlowest is the threshold for the slowest metric ThresholdSlowest = Threshold("slowest") // ThresholdRPS is the threshold for the RPS metric ThresholdRPS = Threshold("rps") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { Model RunID uint `json:"runId"` // The Mark for histogram bucket in seconds Mark float64 `json:"mark"` // The count in the bucket Count int `json:"count"` // The frequency of results in the bucket as a decimal percentage Frequency float64 `json:"frequency"` }
Bucket holds histogram data
type Detail ¶
type Detail struct { Model Run *Run `json:"-"` // Run id RunID uint `json:"runID" gorm:"type:integer REFERENCES runs(id)"` // Timestamp for the detail Timestamp time.Time `json:"timestamp"` // Latency of the call Latency float64 `json:"latency" validate:"required"` // Error details Error string `json:"error"` // Status of the call Status string `json:"status"` }
Detail represents a run detail
func (*Detail) BeforeSave ¶
BeforeSave is called by GORM before save
func (*Detail) UnmarshalJSON ¶
UnmarshalJSON for Detail
type DetailService ¶
DetailService is our implementation
func (*DetailService) Count ¶
func (ds *DetailService) Count(rid uint) (uint, error)
Count returns the total number of runs
func (*DetailService) Create ¶
func (ds *DetailService) Create(r *Detail) error
Create creates a new detail
func (*DetailService) CreateBatch ¶
func (ds *DetailService) CreateBatch(rid uint, s []*Detail) (uint, uint)
CreateBatch creates a batch of details returning the number successfully created, and the number failed
func (*DetailService) Delete ¶
func (ds *DetailService) Delete(r *Detail) error
Delete deletes a detial
func (*DetailService) DeleteAll ¶
func (ds *DetailService) DeleteAll(rid uint) error
DeleteAll deletes all details for a run
func (*DetailService) FindByID ¶
func (ds *DetailService) FindByID(id uint) (*Detail, error)
FindByID finds test by id
func (*DetailService) FindByRunID ¶
func (ds *DetailService) FindByRunID(rid, num, page uint) ([]*Detail, error)
FindByRunID finds tests by project
func (*DetailService) FindByRunIDAll ¶
func (ds *DetailService) FindByRunIDAll(rid uint) ([]*Detail, error)
FindByRunIDAll lists details using sorting
func (*DetailService) FindByRunIDSorted ¶
func (ds *DetailService) FindByRunIDSorted(rid, num, page uint, sortField, order string) ([]*Detail, error)
FindByRunIDSorted lists details using sorting
func (*DetailService) Update ¶
func (ds *DetailService) Update(d *Detail) error
Update updates a detail
type LatencyDistribution ¶
type LatencyDistribution struct { Model RunID uint `json:"runId"` Percentage int `json:"percentage"` Latency time.Duration `json:"latency"` }
LatencyDistribution holds latency distribution data
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"` // The deleted time DeletedAt *time.Time `json:"deletedAt" sql:"index"` }
Model base model definition. Copy of gorm.Model with custom tags
type Options ¶
type Options struct { Call string `json:"call,omitempty"` Proto string `json:"proto,omitempty"` Host string `json:"host,omitempty"` Cert string `json:"cert,omitempty"` CName string `json:"cname,omitempty"` N int `json:"n,omitempty"` C int `json:"c,omitempty"` QPS int `json:"qps,omitempty"` Z time.Duration `json:"z,omitempty"` Timeout int `json:"timeout,omitempty"` DialTimtout int `json:"dialTimeout,omitempty"` KeepaliveTime int `json:"keepAlice,omitempty"` Data interface{} `json:"data,omitempty"` Metadata *map[string]string `json:"metadata,omitempty"` }
Options represents run options
type Project ¶
type Project struct { Model Name string `json:"name" gorm:"unique_index;not null"` Description string `json:"description"` }
Project represents a project
func (*Project) BeforeCreate ¶
BeforeCreate is a GORM hook called when a model is created
func (*Project) BeforeSave ¶
BeforeSave is a GORM hook called when a model is created
func (*Project) BeforeUpdate ¶
BeforeUpdate is a GORM hook called when a model is updated
type ProjectService ¶
ProjectService is our implementation
func (*ProjectService) Count ¶
func (ps *ProjectService) Count() (uint, error)
Count returns the total number of projects
func (*ProjectService) Create ¶
func (ps *ProjectService) Create(p *Project) error
Create creates a new project
func (*ProjectService) Delete ¶
func (ps *ProjectService) Delete(p *Project) error
Delete deletes project
func (*ProjectService) FindByID ¶
func (ps *ProjectService) FindByID(id uint) (*Project, error)
FindByID finds project by id
func (*ProjectService) FindByName ¶
func (ps *ProjectService) FindByName(name string) (*Project, error)
FindByName finds project by name
func (*ProjectService) List ¶
func (ps *ProjectService) List(limit, page uint) ([]*Project, error)
List lists projects
func (*ProjectService) ListSorted ¶
func (ps *ProjectService) ListSorted(limit, page uint, sortField, order string) ([]*Project, error)
ListSorted lists projects using sorting
func (*ProjectService) Update ¶
func (ps *ProjectService) Update(p *Project) error
Update updates project
type Run ¶
type Run struct { Model Date time.Time `json:"date"` TestID uint `json:"testID" gorm:"type:integer REFERENCES tests(id)"` Test *Test `json:"-"` 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" validate:"oneof=ok fail"` Options *Options `json:"options,omitempty" gorm:"-"` ErrorDist map[string]int `json:"errorDistribution,omitempty" gorm:"-"` StatusCodeDist map[string]int `json:"statusCodeDistribution,omitempty" gorm:"-"` LatencyDistribution []*LatencyDistribution `json:"latencyDistribution"` Histogram []*Bucket `json:"histogram"` // temp conversion vars ErrorDistJSON string `json:"-" gorm:"column:error_dist"` StatusCodeDistJSON string `json:"-" gorm:"column:status_code_dist"` OptionsJSON string `json:"-" gorm:"column:options"` }
Run represents a project
func (*Run) BeforeSave ¶
BeforeSave is called by GORM before save
func (*Run) GetThresholdValues ¶
GetThresholdValues gets median and 95th
type RunService ¶
RunService is our implementation
func (*RunService) Count ¶
func (rs *RunService) Count(tid uint) (uint, error)
Count returns the total number of runs
func (*RunService) FindByID ¶
func (rs *RunService) FindByID(id uint) (*Run, error)
FindByID finds run by id
func (*RunService) FindByTestID ¶
func (rs *RunService) FindByTestID(tid, num, page uint, populate bool) ([]*Run, error)
FindByTestID finds tests by project
func (*RunService) FindByTestIDSorted ¶
func (rs *RunService) FindByTestIDSorted(tid, num, page uint, sortField, order string, histogram bool, latency bool) ([]*Run, error)
FindByTestIDSorted lists tests using sorting
func (*RunService) FindLatest ¶
func (rs *RunService) FindLatest(tid uint) (*Run, error)
FindLatest returns the latest created run for test
type Status ¶
type Status string
Status represents a status of a test, whether its latest run failed the threshold settings
func StatusFromString ¶
StatusFromString creates a Status from a string
func (Status) MarshalJSON ¶
MarshalJSON formats a Threshold value into a JSON string
func (*Status) UnmarshalJSON ¶
UnmarshalJSON prases a Threshold value from JSON string
type Test ¶
type Test struct { Model ProjectID uint `json:"projectID" gorm:"type:integer REFERENCES projects(id);unique_index:test_name"` Project *Project `json:"-"` Name string `json:"name" gorm:"unique_index:test_name;not null" validate:"required"` Description string `json:"description"` Status Status `json:"status" validate:"oneof=ok fail"` Thresholds map[Threshold]*ThresholdSetting `json:"thresholds,omitempty" gorm:"-"` KeyMetric Threshold `json:"keyMetric"` FailOnError bool `json:"failOnError"` FailOnThreshold bool `json:"failOnThreshold"` FailOnKeyMetric bool `json:"failOnKeyMetric"` ThresholdsJSON string `json:"-" gorm:"column:thresholds"` }
Test represents a test
func (*Test) BeforeCreate ¶
BeforeCreate is a GORM hook called when a model is created
func (*Test) BeforeSave ¶
BeforeSave is called by GORM before save
func (*Test) BeforeUpdate ¶
BeforeUpdate is a GORM hook called when a model is updated
func (*Test) SetStatus ¶
func (t *Test) SetStatus(tMean, tMedian, t95, fastest, slowest time.Duration, rps float64, hasError bool)
SetStatus sets this test's status based on the settings and the values in params
func (*Test) UnmarshalJSON ¶
UnmarshalJSON prases a Test value from JSON string
type TestService ¶
TestService is our implementation
func (*TestService) Count ¶
func (ts *TestService) Count(pid uint) (uint, error)
Count returns the total number of tests
func (*TestService) Create ¶
func (ts *TestService) Create(t *Test) error
Create creates a new tests
func (*TestService) FindByID ¶
func (ts *TestService) FindByID(id uint) (*Test, error)
FindByID finds test by id
func (*TestService) FindByName ¶
func (ts *TestService) FindByName(pid uint, name string) (*Test, error)
FindByName finds test by name
func (*TestService) FindByProjectID ¶
func (ts *TestService) FindByProjectID(pid, num, page uint) ([]*Test, error)
FindByProjectID finds tests by project
func (*TestService) FindByProjectIDSorted ¶
func (ts *TestService) FindByProjectIDSorted(pid, num, page uint, sortField, order string) ([]*Test, error)
FindByProjectIDSorted lists tests using sorting
type ThresholdSetting ¶
type ThresholdSetting struct { Status Status `json:"status" validate:"oneof=ok fail"` Threshold time.Duration `json:"threshold,omitempty"` NumericalThreshold float64 `json:"numericalThreshold,omitempty"` }
ThresholdSetting setting
func (*ThresholdSetting) UnmarshalJSON ¶
func (m *ThresholdSetting) UnmarshalJSON(data []byte) error
UnmarshalJSON prases a ThresholdSetting value from JSON string