uid

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeOut = errors.New("get uid timeout")

ErrTimeOut 获取uid超时错误

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(num ...uint32) uint32

type Option

type Option func(o *Options)

func DB

func DB(c *gorm.DB) Option

func Fun

func Fun(c CheckFunc) Option

可多次调用

func ID

func ID(c string) Option

func Len

func Len(c uint32) Option

func Logger

func Logger(c logger.Logger) Option

func Table

func Table(c string) Option

type Options

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

func DefaultOptions

func DefaultOptions() Options

type UID

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

UID struct

func New

func New(db *gorm.DB, opts ...Option) (*UID, error)

New 创建一个UID;len:缓冲池大小() db:数据库连接 len:缓冲池大小(长度可控制缓存中剩下多少id时,去DB中加载)

func (*UID) Get

func (e *UID) Get() (uint32, error)

Get 获取自增id,当发生超时,返回错误,避免大量请求阻塞,服务器崩溃

Jump to

Keyboard shortcuts

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