sequence

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 3 Imported by: 1

README

sequence

import "codeberg.org/mgkeller/go-sequence"

Overview

Package sequence provides a performant goro-safe incrementing sequencer, with randomized HashID-encoding of the values to work as a font of IDs for errors, requests, etc.

Index

Package files

seq.go

type Seq

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

Seq is a sequencer. It should never be used by default, and instead obtained via a New function

func New
func New(start int) *Seq

New returns an initialized Seq suitable for most cases

func NewWithHashIDLength
func NewWithHashIDLength(start, hashIDlength int) *Seq

NewWithHashIDLength returns an initilized Seq with the minimum hashID length set as specified

func (*Seq) Next
func (s *Seq) Next() int

Next returns the next int in the sequence

func (*Seq) NextHashID
func (s *Seq) NextHashID() string

NextHashID returns the hashID-encoded value of the next int in the sequence


Generated by godoc2md

Documentation

Overview

Package sequence provides a performant goro-safe incrementing sequencer, with randomized HashID-encoding of the values to work as a font of IDs for errors, requests, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Seq

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

Seq is a sequencer. It should never be used by default, and instead obtained via a New function

func New

func New(start int) *Seq

New returns an initialized Seq suitable for most cases

func NewWithHashIDLength

func NewWithHashIDLength(start, hashIDlength int) *Seq

NewWithHashIDLength returns an initilized Seq with the minimum hashID length set as specified

func (*Seq) Next

func (s *Seq) Next() int

Next returns the next int in the sequence

func (*Seq) NextHashID

func (s *Seq) NextHashID() string

NextHashID returns the hashID-encoded value of the next int in the sequence

Jump to

Keyboard shortcuts

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