server

package
v0.0.0-...-118f6c1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Timestamp oracle server listen address
	Addr string

	// zookeeper address, format is zk1,zk2..., split by ,.
	// if empty, the tso server is just a standalone memory server, and
	// can't save lastest timestamp, so you may only use empty zk address in test.
	ZKAddr string

	// root path for saving data in zookeeper, the path must has the magic preifx /zk first,
	RootPath string

	// SaveInterval is the interval time (ms) to save timestamp in zookeeper.
	// When the leader begins to run, it first loads the saved timestamp from zookeeper, e.g, T1,
	// and the leader must guarantee that the next timestamp must be > T1 + 2 * SaveInterval.
	SaveInterval int64
}

Config is the configuration for timestamp oracle server

type TimestampOracle

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

TimestampOracle generates a unique timestamp.

func NewTimestampOracle

func NewTimestampOracle(cfg *Config) (*TimestampOracle, error)

NewTimestampOracle creates a tso server with special config.

func (*TimestampOracle) Close

func (tso *TimestampOracle) Close()

Close closes timestamp oracle server.

func (*TimestampOracle) IsLeader

func (tso *TimestampOracle) IsLeader() bool

IsLeader returns whether tso is leader or not.

func (*TimestampOracle) ListenAddr

func (tso *TimestampOracle) ListenAddr() string

ListenAddr returns listen address. You must call it after tso server accepts successfully.

func (*TimestampOracle) Run

func (tso *TimestampOracle) Run() error

Run runs the timestamp oracle server.

func (*TimestampOracle) String

func (tso *TimestampOracle) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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