dcsid

package module
v0.0.0-...-6ff2234 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 5 Imported by: 0

README

dcsid

分布式ID生成

Install:

go get github.com/cacos-group/dcsid

数据表

CREATE TABLE `dcsid_alloc` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `biz_tag` varchar(128) NOT NULL DEFAULT '',
  `max_id` bigint(20) NOT NULL DEFAULT '1',
  `step` int(11) NOT NULL,
  `description` varchar(256) DEFAULT NULL,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  unique `uniq_biz_tag` (`biz_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

使用

dcsid := New(&Config{
	DSN:    "user:password@tcp(127.0.0.1:3306)/dcsid",
	BizTag: "test",
})
id, err := dcsid.NextId()
if err != nil {
    
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IDPool0EmptyErr = fmt.Errorf("idPool0 empty")

Functions

This section is empty.

Types

type Client

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

func New

func New(config *Config) *Client

func (*Client) NextId

func (l *Client) NextId() (uint64, error)

type Config

type Config struct {
	DSN    string // write data source name.
	BizTag string
	Step   int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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