service

package
v0.0.0-...-62cb6d9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomDialer

func CustomDialer(ctx context.Context, network, addr string) (net.Conn, error)

CustomDialer ..need to figure how to pass ID & channel for this

func SocketRun

func SocketRun(hostURL string, timeout int, tests []*models.Test, dataIdx int, doneChan chan bool, errChan chan error, hitIdx int, reporterChan chan *models.SocketStats)

SocketRun goroutine that makes a socket collection with the host and starts the tests

Types

type ContextKey

type ContextKey string

ContextKey used for getting ref out of context

type DataHandler

type DataHandler struct{}

DataHandler handles all data

func (*DataHandler) ConstructDataConfig

func (d *DataHandler) ConstructDataConfig(message json.RawMessage) []*models.TestDataConfig

ConstructDataConfig finds the index and CSV column frpom which data needs to be replaced in the test message string

func (*DataHandler) GetCSVData

func (d *DataHandler) GetCSVData(path string, rows int) ([][]string, error)

GetCSVData reads the data file and populates a string array with the values

func (*DataHandler) PrepareTestData

func (d *DataHandler) PrepareTestData(file string, connCount int, tests []*models.Test) int

PrepareTestData prepares the test data for each test

type Runner

type Runner struct {
	TestDoneChan    chan bool
	SocketDoneChan  chan bool
	SocketDoneCount int
	TotalCount      int
	ErrChan         chan error
	HostURL         string
	ConnectTimeout  int
	MaxDataLength   int
	DataIndex       int
	Tests           []*models.Test
	HitRates        []models.HitRate
	Flows           []models.ConnectionBucket
}

Runner Handles all the running of tests & running config

var TestRunner Runner

TestRunner singleton runner that will run tests

func (*Runner) CompleteNotify

func (r *Runner) CompleteNotify()

CompleteNotify is notified when a socket test completes

func (*Runner) ErrorListener

func (r *Runner) ErrorListener()

ErrorListener prints out errors

func (*Runner) Initialize

func (r *Runner) Initialize()

Initialize initializes the runner with config and channels

func (*Runner) OpenSocket

func (r *Runner) OpenSocket(hitIdx int)

OpenSocket opens a socket.. this was repeated code

func (*Runner) PrepareBuckets

func (r *Runner) PrepareBuckets()

PrepareBuckets prepares buckets per second of number of socket connections to open

func (*Runner) RunTests

func (r *Runner) RunTests()

RunTests runs the tests according to the flow

func (*Runner) Start

func (r *Runner) Start()

Start starts the tests

type Socket

type Socket struct {
	Connection  *websocket.Conn
	Dialer      *websocket.Dialer
	SocketStats *models.SocketStats
	Context     context.Context
}

Socket = single socket connection to the host

func (*Socket) Connect

func (s *Socket) Connect(url string) error

Connect connect the ws to host

func (*Socket) DoTests

func (s *Socket) DoTests(tests []*models.Test, dataIdx int)

DoTests runs through tests for this socket

type StatsReporter

type StatsReporter struct {
	RateStats     map[int]*models.HitRateStats
	AllStats      *models.HitRateStats
	ReportChan    chan *models.SocketStats
	TestDoneChan  chan bool
	ReportString  string
	HitrateString string
	TabWriter     *tabwriter.Writer
	StatsdClient  *statsd.StatsdClient
	StatsStrings  struct {
		Success        string
		Failure        string
		ConnectLatency string
		DNSLatency     string
		OverallLatency string
	}
}

StatsReporter is the struct that holds all test stats

var Reporter StatsReporter

Reporter singleton object

func (*StatsReporter) ConnectDameon

func (r *StatsReporter) ConnectDameon()

ConnectDameon connect reporter module to connect to any third party reporting tool like a statsd daemon

func (*StatsReporter) GetMinMax

func (r *StatsReporter) GetMinMax(val time.Duration, min float64, max float64) (float64, float64)

GetMinMax gets min & max after comparing the values

func (*StatsReporter) LogHitrate

func (r *StatsReporter) LogHitrate(hitrate *models.HitRate)

LogHitrate logs the current hitrate

func (*StatsReporter) MakeHitRateStat

func (r *StatsReporter) MakeHitRateStat(idx int, hitrate models.HitRate)

MakeHitRateStat makes a stat object based on the hitrate id

func (*StatsReporter) MeasureLatencies

func (r *StatsReporter) MeasureLatencies(hrStat *models.HitRateStats, metric *models.SocketStats)

MeasureLatencies measures latencies when a metric comes in

func (*StatsReporter) Report

func (r *StatsReporter) Report(hrStat *models.HitRateStats)

Report prints out the stats as they currently stand

func (*StatsReporter) ReportStatsd

func (r *StatsReporter) ReportStatsd(metric *models.SocketStats)

ReportStatsd reporting latencies out to statsd

func (*StatsReporter) Start

func (r *StatsReporter) Start()

Start starts the reporter to listen to any metric data coming on channel

Jump to

Keyboard shortcuts

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