Movatterモバイル変換


[0]ホーム

URL:


notify

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:5Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeCondition

type Condition func(nowtime.Time) (deadlinetime.Time, callback func())

Condition is a function that gets executed periodically, and receives thecurrent time as an argument.

  • It should return the deadline for the notification, as well as acallback function to execute. If deadline is the zerotime, callback will not be executed.
  • Callback is executed once for every time the difference between deadlineand the current time is less than an element of countdown.
  • To enforce a minimum interval between consecutive callbacks, truncatethe returned deadline to the minimum interval.

typeNotifier

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

Notifier triggers callbacks at given intervals until some event happens. Theintervals (e.g. 10 minute warning, 5 minute warning) are given in thecountdown. The Notifier periodically polls the condition to get the time ofthe event (the Condition's deadline) and the callback. The callback iscalled at most once per entry in the countdown, the first time the time tothe deadline is shorter than the duration.

funcNew

func New(condCondition, intervaltime.Duration, countdown []time.Duration, opts ...Option) *Notifier

New returns a Notifier that calls cond once every time it polls.

  • Duplicate values are removed from countdown, and it is sorted indescending order.

func (*Notifier)Close

func (n *Notifier) Close()

typeOptionadded inv2.13.0

type Option func(*Notifier)

funcWithTestClockadded inv2.13.0

func WithTestClock(clkquartz.Clock)Option

WithTestClock is used in tests to inject a mock Clock

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp