timerecord

package
v0.0.2-0...-993051b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

func NewChecker

func NewChecker(name string, manager *CheckerManager) *Checker

func (*Checker) Check

func (checker *Checker) Check()

func (*Checker) Close

func (checker *Checker) Close()

type CheckerManager

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

CheckerManager checks members in same group silent for certain period of time print warning msg if there are item(s) that not reported

func GetCheckerManger

func GetCheckerManger(groupName string, duration time.Duration, fn func([]string)) *CheckerManager

GetGroupChecker returns the GroupChecker with related group name if no exist GroupChecker has the provided name, a new instance will be created with provided params otherwise the params will be ignored

func (*CheckerManager) Register

func (gc *CheckerManager) Register(name string, checker *Checker)

func (*CheckerManager) Remove

func (gc *CheckerManager) Remove(name string)

Remove deletes name from watch list

func (*CheckerManager) Stop

func (gc *CheckerManager) Stop()

Stop closes the GroupChecker

type LongTermChecker

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

LongTermChecker checks we receive at least one msg in d duration. If not, checker will print a warn message.

func NewLongTermChecker

func NewLongTermChecker(ctx context.Context, name string, d time.Duration, warn string) *LongTermChecker

NewLongTermChecker creates a long term checker specified name, checking interval and warning string to print

func (*LongTermChecker) Check

func (c *LongTermChecker) Check()

Check resets the time ticker

func (*LongTermChecker) Start

func (c *LongTermChecker) Start()

Start starts the check process

func (*LongTermChecker) Stop

func (c *LongTermChecker) Stop()

Stop stops the checker

type TimeRecorder

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

TimeRecorder provides methods to record time duration

func NewTimeRecorder

func NewTimeRecorder(header string) *TimeRecorder

NewTimeRecorder creates a new TimeRecorder

func NewTimeRecorderWithTrace

func NewTimeRecorderWithTrace(ctx context.Context, header string) *TimeRecorder

NewTimeRecorderWithCtx creates a new TimeRecorder with context's traceID,

func (*TimeRecorder) CtxElapse

func (tr *TimeRecorder) CtxElapse(ctx context.Context, msg string) time.Duration

func (*TimeRecorder) CtxRecord

func (tr *TimeRecorder) CtxRecord(ctx context.Context, msg string) time.Duration

func (*TimeRecorder) Elapse

func (tr *TimeRecorder) Elapse(msg string) time.Duration

Elapse calculates the time span from the beginning of this TimeRecorder

func (*TimeRecorder) ElapseSpan

func (tr *TimeRecorder) ElapseSpan() time.Duration

ElapseSpan returns the duration from the beginning

func (*TimeRecorder) Record

func (tr *TimeRecorder) Record(msg string) time.Duration

Record calculates the time span from previous Record call

func (*TimeRecorder) RecordSpan

func (tr *TimeRecorder) RecordSpan() time.Duration

RecordSpan returns the duration from last record

Jump to

Keyboard shortcuts

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