idle

package
v0.750.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIdle = fmt.Errorf("service is inactive")

ErrIdle indicates that, according to the Watcher configuration, the service is idle.

View Source
var TickInterval = 5 * time.Second

TickInterval is the interval at which to check the proxy activity.

Functions

func RecordActivity

func RecordActivity(id string)

RecordActivity records activity for a idler. ID must be a globally unique identifier for the idler.

func Register

func Register(cfg sproto.IdleTimeoutConfig, action TimeoutFn)

Register an idler to default service. The action is called at most once when the idle timeout is exceeded. The action can trigger until Unregister is called. ID must be a globally unique identifier for the idler.

func Unregister

func Unregister(id string)

Unregister removes an idler from the service. ID must be a globally unique identifier for the idler.

Types

type TimeoutFn

type TimeoutFn func(context.Context, error)

TimeoutFn is called when the service is idle.

type Watcher

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

Watcher watches the proxy activity to handle a task actor idle timeout.

func New

func New(cfg sproto.IdleTimeoutConfig, action TimeoutFn) *Watcher

New creates a new idle timeout watcher. The action can be triggered until Close is called.

func (*Watcher) Close

func (w *Watcher) Close()

Close closes the idle timeout watcher.

func (*Watcher) RecordActivity

func (w *Watcher) RecordActivity(instant time.Time)

RecordActivity notes the activity to delay idle timeout.

Jump to

Keyboard shortcuts

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