snapshot

package
v0.0.0-...-57f3b98 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

package snapshot implements redis-snapshot like mechanism - the higher the frequency, the more frequent the execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New

func New(policies []Policy) *Manager

func (*Manager) Exec

func (m *Manager) Exec(ctx context.Context, h func(ctx context.Context))

Exec allows lazy execution.

func (*Manager) Inc

func (m *Manager) Inc(n int64) int64

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, h func(ctx context.Context)) func()

Run executes whenever the condition is fulfilled. Returning an error will cause the every and timer not to reset. The client should be responsible for logging and handling the error.

type Policy

type Policy struct {
	Every    int64
	Interval time.Duration
}

func NewPolicy

func NewPolicy(every int64, interval time.Duration) Policy

func (Policy) IntervalSeconds

func (p Policy) IntervalSeconds() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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