sampler

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenSlots

type OpenSlots struct {
	T     int `bson:"t" json:"t"`
	Value int `bson:"value" json:"value"`
}

type SampleInfos added in v0.6.0

type SampleInfos struct {
	CurrentTime     int64 `json:"currentTimeInInterval"`
	OpenSlotsTarget int   `json:"openSlotsTarget"`
	UsedSlots       int   `json:"usedSlots"`
	AvailableSlots  int   `json:"availableSlots"`
	MaxSlots        int   `json:"maxSlots"`
}

type Sampler

type Sampler struct {
	SlotCurve SlotCurve
	// contains filtered or unexported fields
}

func NewSampler

func NewSampler(
	instanceID string,
	dbService SamplerDBService,
) *Sampler

func (Sampler) GetSamplerInfos added in v0.6.0

func (s Sampler) GetSamplerInfos() SampleInfos

func (Sampler) HasAvailableFreeSlots

func (s Sampler) HasAvailableFreeSlots() bool

func (*Sampler) InitFromSampleCSV

func (s *Sampler) InitFromSampleCSV(filePath string, target int, minVal int)

func (*Sampler) LoadSlotCurveFromDB

func (s *Sampler) LoadSlotCurveFromDB()

func (Sampler) NeedsRefresh

func (s Sampler) NeedsRefresh() bool

func (Sampler) SaveSlotCurveToDB

func (s Sampler) SaveSlotCurveToDB()

type SamplerDBService

type SamplerDBService interface {
	LoadLatestSlotCurve(instanceID string) (res SlotCurve, err error)
	SaveNewSlotCurve(instanceID string, res SlotCurve) (err error)
	GetUsedSlotsCountSince(instanceID string, ref int64) (count int64, err error)
}

type SlotCurve

type SlotCurve struct {
	ID            primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	IntervalStart int64              `bson:"intervalStart,omitempty" json:"intervalStart,omitempty"`
	OpenSlots     []OpenSlots        `bson:"openSlots,omitempty" json:"openSlots,omitempty"`
}

Jump to

Keyboard shortcuts

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