wallclockticker

package module
v0.0.0-...-a0c87ed Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: BSD-2-Clause Imports: 1 Imported by: 0

README

golang-action status

wall-clock-ticker

Golang wall clock ticker is a Go library that provides a ticker which ticks according to wall clock.

Installation

go get -u github.com/filinvadim/wall-clock-ticker

Usage

Using Golang wall clock ticker is very much like time.NewTicker with the addition of an accuracy and start time.

The following creates a ticker which ticks on the minute according the hosts wall clock with an accuracy of plus or minus one second.

package main

import (
	"fmt"
	"time"

	wct "github.com/filinvadim/wall-clock-ticker"
)

func main() {
	// ticks every 59th minute of every hour
	t := wct.NewWCTicker(time.Minute*59, time.Second)
	for tick := range t.C {
		// Process tick
		fmt.Println("tick:", tick)
	}
}

License

Golang wall clock ticker is available under the BSD 2-Clause License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WCTicker

type WCTicker struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

func NewCWTicker

func NewCWTicker(clockArrowsPosition, accuracy time.Duration) *WCTicker

func (*WCTicker) Stop

func (t *WCTicker) Stop()

Jump to

Keyboard shortcuts

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