timerecord

package
v0.0.0-...-1593278 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupChecker

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

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

func GetGroupChecker

func GetGroupChecker(groupName string, duration time.Duration, fn func([]string)) *GroupChecker

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 (*GroupChecker) Check

func (gc *GroupChecker) Check(name string)

Check updates the latest timestamp for provided name

func (*GroupChecker) Remove

func (gc *GroupChecker) Remove(name string)

Remove deletes name from watch list

func (*GroupChecker) Stop

func (gc *GroupChecker) 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