durable

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package durable contains validation shared by public construction and the PostgreSQL store for values whose durable representation is narrower than their Go representation.

Index

Constants

View Source
const (
	PostgresIntegerMin = int64(math.MinInt32)
	PostgresIntegerMax = int64(math.MaxInt32)
)

Variables

This section is empty.

Functions

func AddExactDuration

func AddExactDuration(field string, base time.Time, value time.Duration) (time.Time, error)

AddExactDuration makes validation precede durable timestamp arithmetic.

func AddPostgresInteger

func AddPostgresInteger(field string, value, delta int, minimum, maximum int64) (int, error)

AddPostgresInteger validates a PostgreSQL integer transition without doing architecture-sized arithmetic first.

func CeilMilliseconds added in v0.3.0

func CeilMilliseconds(field string, value time.Duration) (time.Duration, int64, error)

CeilMilliseconds normalizes a non-negative public duration upward to its durable whole-millisecond representation. Feature-specific callers retain ownership of zero semantics. Values whose ceiling cannot be represented as a time.Duration are rejected instead of wrapping.

func ExactMilliseconds

func ExactMilliseconds(field string, value time.Duration) (int64, error)

ExactMilliseconds converts a non-negative duration to its durable whole- millisecond representation. Callers enforce feature-specific zero semantics.

func MillisecondsDuration

func MillisecondsDuration(field string, value int64) (time.Duration, error)

MillisecondsDuration converts a non-negative durable millisecond value to a Go duration without overflowing the narrower nanosecond representation.

func PostgresInteger

func PostgresInteger(field string, value int, minimum, maximum int64) error

PostgresInteger validates a Go int before it is written to a PostgreSQL integer. Bounds are int64 so the same call is correct on 32- and 64-bit Go.

func PostgresInteger32

func PostgresInteger32(field string, value int, minimum, maximum int64) (int32, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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