Help us shape the future of Go! Take the 2026 Go Developer Survey

ratewindow

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ratewindow owns the shared exact timestamp domain and per-key window phase for rate authorities. Go adapters and the Redis script apply the same arithmetic, so every authority sharing a key agrees on its window boundaries.

Index

Constants

View Source
const MaxTimestamp int64 = 1<<53 - 1

MaxTimestamp is the greatest exact integer shared by Go and Redis Lua numbers.

Variables

This section is empty.

Functions

func End

func End(now, window, offset int64) (int64, error)

End returns the end of the window containing now, for windows starting at offset + n*window. The result is in (now, now+window].

func Offset

func Offset(seed, window int64) int64

Offset returns a key's window phase in [0, window). Windows then start at offset + n*window instead of Unix-epoch multiples, so buckets of many keys do not all reset at the same instant. A nonpositive window has no phase.

func Seed

func Seed(digest [32]byte) int64

Seed derives a deterministic phase seed from a key's address digest. It is bounded to 48 bits so Lua numbers (IEEE doubles) represent it exactly.

Types

This section is empty.

Jump to

Keyboard shortcuts

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