resource

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package resource implements virtual resources, which simulate some real-world resources without actually consuming them.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRPCTimeout  = errors.New("RPC timed out")
	ErrRPCInternal = errors.New("RPC failed")
)

Errors.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	// contains filtered or unexported fields
}

CPU implements app.CPU interface.

func NewCPU

func NewCPU(hz int) *CPU

NewCPU creates and returns new CPU.

func (*CPU) Consume

func (c *CPU) Consume(ctx Ctx, t time.Duration) error

Consume implements app.CPU interface.

func (*CPU) Provide

func (c *CPU) Provide(ctx Ctx) error

Provide should be started in background once per each CPU instance. It'll return nil when ctx is done.

When Provide is not running Consume won't be able to consume resources and will return only when their ctx is done.

type Ctx

type Ctx = context.Context

type LicenseSvc

type LicenseSvc struct {
	// contains filtered or unexported fields
}

LicenseSvc implements app.LicenseSvc interface.

func NewLicenseSvc

func NewLicenseSvc(cfg LicenseSvcConfig) *LicenseSvc

NewLicenseSvc creates and returns new LicenseSvc.

func (*LicenseSvc) Call

func (s *LicenseSvc) Call(ctx Ctx, percentFail int) (err error)

Call implements app.LicenseSvc interface.

type LicenseSvcConfig

type LicenseSvcConfig struct {
	Seed           int64
	PercentTimeout int
	MinDelay       time.Duration
	MaxDelay       time.Duration
	TimeoutDelay   time.Duration
}

LicenseSvcConfig contains configuration for LicenseSvc.

Jump to

Keyboard shortcuts

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