bizno

package
v0.0.0-...-d5b0b98 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxWorkID is the maximum number of workers
	MaxWorkID = 65536
)

Variables

View Source
var (
	KeyGeneratorNodeNum = "/evhub/generator/node/num"
	KeyGeneratorNode    = "/evhub/generator/node/num/%v"
)

Functions

func KeyGeneratorNodeKey

func KeyGeneratorNodeKey(nodeNum int64) string

KeyGeneratorNodeKey returns the key generator node for the given node number

Types

type Config

type Config struct {
	// EtcdEndpoints is the list of endpoints to connect to the etcd
	EtcdEndpoints []string
	// EtcdDialTimeout is the name of the etcd dial timeout
	EtcdDialTimeout time.Duration
	// GeneratorNum is the number of generators
	GeneratorNum int
}

Config is the configuration for the biz number generator

type Generator

type Generator interface {
	NextID() (string, error)
}

Generator is the interface for creating a new biz number generator

func NewGenerator

func NewGenerator(etcdCli *clientv3.Client) (Generator, error)

NewGenerator creates a new generator for the given configuration

type Pool

type Pool interface {
	NextID() (string, error)
}

Pool is the interface for creating a new biz number generator pool

func NewPool

func NewPool(c *Config) (Pool, error)

NewPool creates a new biz number generator pool

Jump to

Keyboard shortcuts

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