Git Product home page Git Product logo

seqsvr's Introduction

SEQSVR

High performance unique number generator powered by Go

δΈ­ζ–‡ README

Features

  • Distributed: Can be scaled horizontally
  • High performance: Allocation ID only accesses memory (up to the upper limit will request the database once)
  • Ease of use: Provide as HTTP service
  • Unique: MySQL auto increment ID, never repeat

Requirement

We are using these awesome projects as necessary libraries.

  • gopkg.in/yaml.v2
  • github.com/go-sql-driver/mysql
  • github.com/satori/go.uuid

Installation

You can install this service in the following three ways.

Note: You need to create the database and modify the configuration of the database in the configuration file before starting.

go get:

go get github.com/qichengzx/seqsvr
seqsvr

Compile By Yourself:

git clone [email protected]:qichengzx/seqsvr.git
cd seqsvr
go build .
./seqsvr

Docker:

The Docker "multi-stage" build feature is used, be ensure the Docker version is 17.05 or above. See:Use multi-stage builds

git clone [email protected]:qichengzx/seqsvr.git
cd seqsvr
docker build seqsvr:latest .
docker run -p 8000:8000 seqsvr:latest

Create Database

The database name can be customized, modify config.yml.

Then import the following SQL to generate the data table.

CREATE TABLE `generator_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` char(36) NOT NULL COMMENT 'Machine identification',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_UNIQUE` (`id`),
  UNIQUE KEY `stub_UNIQUE` (`uuid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Configuration

The configuration file is using YAML.

#app
port: ':8000'

#service
step: 100

#db
mysql:
  user: 'root'
  password: ''
  host: 'tcp(localhost:3306)'
  database: 'sequence'
  maxidle: 2
  maxopen: 10

Usage

curl http://localhost:8000/new

{"code":0,"msg":"ok","data":{"id":101}}

seqsvr's People

Contributors

qichengzx avatar xingqijiuxueyuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.