server

package
v0.0.0-...-8f5302c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StartOfContainerID the first ID that the container starts to assgin.
	StartOfContainerID = 10
	// StartOfServerID the first ID that the server starts to assgin.
	StartOfServerID = 10
	// StartOfSequence the first ID that the sequence starts to assgin.
	StartOfSequence = 1
	// MaxOfSequence the maximum of the sequence.
	MaxOfSequence = 1 << 31

	// KeyOfMaxContainerID holds the key for the maximum container ID.
	KeyOfMaxContainerID = "max_containerid"
	// KeyOfMaxServiceID holds the key for the maximum service ID.
	KeyOfMaxServiceID = "max_serviceid"

	// KeyOfContainerDir the directory where the key value is saved.
	KeyOfContainerDir = "container"
	// KeyOfServiceDir the directory where the key value is saved.
	KeyOfServiceDir = "service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Endpoints defines a set of URLs
	Endpoints []string
	// Username specifies the user credential to add as an authorization header
	UserName string
	// Password is the password for the specified user to add as an authorization header
	// to the request.
	Password string

	// ListenAddress the server listens for local address.
	ListenAddress string
	// Prefix path prefix saved in the etcd.
	Prefix string
}

Config the config used to create the server.

type EtcdWrap

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

EtcdWrap Encapsulation of etcd

func NewEtcdWrap

func NewEtcdWrap(cfg *EtcdWrapConfig) (w *EtcdWrap, err error)

NewEtcdWrap create a new etcd wrap.

func (*EtcdWrap) AtomAdd

func (w *EtcdWrap) AtomAdd(key string, value int) (int, error)

AtomAdd add value to the value atom of key.

func (*EtcdWrap) Delete

func (w *EtcdWrap) Delete(key string) (*client.Response, error)

Delete removes a Node identified by the given key.

func (*EtcdWrap) Get

func (w *EtcdWrap) Get(key string) (*client.Response, error)

Get retrieves a set of Nodes from etcd

func (*EtcdWrap) GetNCreate

func (w *EtcdWrap) GetNCreate(key string, createValue int) (*client.Response, error)

GetNCreate retrieves a set of Nodes from etcd, created if not present.

func (*EtcdWrap) GetVersion

func (w *EtcdWrap) GetVersion() (*version.Versions, error)

GetVersion retrieves the current etcd server and cluster version.

func (*EtcdWrap) IsKeyExist

func (w *EtcdWrap) IsKeyExist(err error) bool

IsKeyExist returns true if the error code is ErrorCodeNodeExist.

func (*EtcdWrap) IsKeyNotFound

func (w *EtcdWrap) IsKeyNotFound(err error) bool

IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound.

func (*EtcdWrap) Set

func (w *EtcdWrap) Set(key string, value string, opts *client.SetOptions) (*client.Response, error)

Set assigns a new value to a Node identified by a given key.

type EtcdWrapConfig

type EtcdWrapConfig struct {
	// Endpoints defines a set of URLs
	Endpoints []string
	// Username specifies the user credential to add as an authorization header
	UserName string
	// Password is the password for the specified user to add as an authorization header
	// to the request.
	Password string
}

EtcdWrapConfig config struct

type UUIDServer

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

UUIDServer UUID server.

func StartServer

func StartServer(cfg *Config) (*UUIDServer, error)

StartServer create a server and run it.

func (*UUIDServer) Fetch

func (s *UUIDServer) Fetch(ctx context.Context, in *api.FetchRequest) (*api.FetchReply, error)

Fetch get UUID range through the server.

func (*UUIDServer) ReassignContainerID

func (s *UUIDServer) ReassignContainerID(containerName string) error

ReassignContainerID reassign an ID to the container.

Jump to

Keyboard shortcuts

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