fakesrvrdata

package
v6.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesPerSec

type BytesPerSec struct {
	Min FakeRemap
	Max FakeRemap
}

type FakeATS

type FakeATS struct {
	Server string `json:"server"`
	Remaps map[string]FakeRemap
}

func (FakeATS) MarshalJSON

func (a FakeATS) MarshalJSON() ([]byte, error)

type FakeProcLoadAvg

type FakeProcLoadAvg struct {
	CPU1m        float64
	CPU5m        float64
	CPU10m       float64
	RunningProcs int
	TotalProcs   int
	LastPIDUsed  int
}

func (FakeProcLoadAvg) MarshalJSON

func (p FakeProcLoadAvg) MarshalJSON() ([]byte, error)

type FakeProcNetDev

type FakeProcNetDev struct {
	Interface      string
	RcvBytes       uint64
	RcvPackets     uint64
	RcvErrs        uint64
	RcvDropped     uint64
	RcvFIFOErrs    uint64
	RcvFrameErrs   uint64
	RcvCompressed  uint64
	RcvMulticast   uint64
	SndBytes       uint64
	SndPackets     uint64
	SndErrs        uint64
	SndDropped     uint64
	SndFIFOErrs    uint64
	SndCollisions  uint64
	SndCarrierErrs uint64
	SndCompressed  uint64
}

func (FakeProcNetDev) MarshalJSON

func (p FakeProcNetDev) MarshalJSON() ([]byte, error)

type FakeRemap

type FakeRemap struct {
	InBytes   uint64
	OutBytes  uint64
	Status2xx uint64
	Status3xx uint64
	Status4xx uint64
	Status5xx uint64
}

type FakeServerData

type FakeServerData struct {
	ATS    FakeATS    `json:"ats"`
	System FakeSystem `json:"system"`
}

func (*FakeServerData) GetSystem

func (s *FakeServerData) GetSystem() FakeServerSystem

GetSystem returns a FakeServerSystem, which can be serialized as the JSON response of Astats with an "application=system" query

type FakeServerSystem

type FakeServerSystem struct {
	ATS    FakeSystemATS `json:"ats"`
	System FakeSystem    `json:"system"`
}

type FakeSystem

type FakeSystem struct {
	Name                 string          `json:"inf.name"`
	Speed                int             `json:"inf.speed"`
	ProcNetDev           FakeProcNetDev  `json:"proc.net.dev"`
	ProcLoadAvg          FakeProcLoadAvg `json:"proc.loadavg"`
	ConfgiReloadRequests uint64          `json:"configReloadRequests"`
	LastReloadRequest    uint64          `json:"lastReloadRequest"`
	ConfigReloads        uint64          `json:"configReloads"`
	LastReload           uint64          `json:"lastReload"`
	AstatsLoad           uint64          `json:"astatsLoad"`
	Something            string          `json:"something"`
	Version              string          `json:"application_version"`
}

type FakeSystemATS

type FakeSystemATS struct {
	Server string `json:"server"`
}

type IncrementChanT

type IncrementChanT struct {
	RemapName   string
	BytesPerSec BytesPerSec
}

type MinMaxUint64

type MinMaxUint64 struct {
	Min uint64
	Max uint64
}

type Ths

type Ths struct {

	// IncrementChan may be used to set the increments for a particular remap.
	// Note this is not synchronized with GetIncrementChan, so multiple writers calling GetIncrementChan and IncrmeentChan to get and set will race, unless they are externally synchronized.
	IncrementChan chan IncrementChanT
	// GetIncrementsChan may be used to get the current increments for all remaps.
	// The returned map must not be modified.
	// Note this is not synchronized with GetIncrementChan, so multiple writers calling GetIncrementChan and IncrmeentChan to get and set will race, unless they are externally synchronized.
	GetIncrementsChan chan map[string]BytesPerSec

	// DelayMS is the minimum and maximum delay to serve requests, in milliseconds.
	// Atomic - MUST be accessed with sync/atomic.LoadUintptr and sync/atomic.StoreUintptr.
	DelayMS *unsafe.Pointer
	// contains filtered or unexported fields
}

Ths provides threadsafe access to a ThsT pointer. Note the object itself is not safe for multiple access, and must not be mutated, either by the original owner after calling Set, or by future users who call Get. If you need to mutate, perform a deep copy.

func NewThs

func NewThs() Ths

func Run

func Run(s FakeServerData, remapIncrements map[string]BytesPerSec) (Ths, error)

Run takes a FakeServerData and a config, and starts running it, incrementing stats per the config. Returns a Threadsafe accessor to the running FakeServerData pointer, whose value may be accessed, but MUST NOT be modified. TODO add increments for Rcv,SndPackets, ProcLoadAvg variance, ConfigReloads

func (Ths) Get

func (t Ths) Get() ThsT

func (Ths) Set

func (t Ths) Set(v ThsT)

type ThsT

type ThsT *FakeServerData

Jump to

Keyboard shortcuts

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