store

package
v2.1.0-beta.3+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: Apache-2.0 Imports: 15 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// EventTypeNew event type new
	EventTypeNew = EvtType(0)
	// EventTypeUpdate event type update
	EventTypeUpdate = EvtType(1)
	// EventTypeDelete event type delete
	EventTypeDelete = EvtType(2)
)
View Source
const (
	// EventSrcCluster cluster event
	EventSrcCluster = EvtSrc(0)
	// EventSrcServer server event
	EventSrcServer = EvtSrc(1)
	// EventSrcBind bind event
	EventSrcBind = EvtSrc(2)
	// EventSrcAPI api event
	EventSrcAPI = EvtSrc(3)
	// EventSrcRouting routing event
	EventSrcRouting = EvtSrc(4)
	// EventSrcProxy routing event
	EventSrcProxy = EvtSrc(5)
)
View Source
const (
	// DefaultTimeout default timeout
	DefaultTimeout = time.Second * 3
	// DefaultRequestTimeout default request timeout
	DefaultRequestTimeout = 10 * time.Second
	// DefaultSlowRequestTime default slow request time
	DefaultSlowRequestTime = time.Second * 1
)

Variables

View Source
var (
	// TICKER ticket
	TICKER = time.Second * 3
	// TTL timeout
	TTL = int64(5)
)
View Source
var (
	// ErrHasBind error has bind into, can not delete
	ErrHasBind = errors.New("Has bind info, can not delete")
	// ErrStaleOP is a stale error
	ErrStaleOP = errors.New("stale option")
)

Functions

This section is empty.

Types

type EtcdStore

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

EtcdStore etcd store impl

func (*EtcdStore) AddBind

func (e *EtcdStore) AddBind(bind *metapb.Bind) error

AddBind bind a server to a cluster

func (*EtcdStore) Clean

func (e *EtcdStore) Clean() error

Clean clean data in store

func (*EtcdStore) GetAPI

func (e *EtcdStore) GetAPI(id uint64) (*metapb.API, error)

GetAPI returns the api

func (*EtcdStore) GetAPIs

func (e *EtcdStore) GetAPIs(limit int64, fn func(interface{}) error) error

GetAPIs returns all api

func (*EtcdStore) GetBindServers

func (e *EtcdStore) GetBindServers(id uint64) ([]uint64, error)

GetBindServers return cluster binds servers

func (*EtcdStore) GetCluster

func (e *EtcdStore) GetCluster(id uint64) (*metapb.Cluster, error)

GetCluster returns the cluster

func (*EtcdStore) GetClusters

func (e *EtcdStore) GetClusters(limit int64, fn func(interface{}) error) error

GetClusters returns all clusters

func (*EtcdStore) GetProxies

func (e *EtcdStore) GetProxies(limit int64, fn func(*metapb.Proxy) error) error

GetProxies returns proxies in store

func (*EtcdStore) GetRouting

func (e *EtcdStore) GetRouting(id uint64) (*metapb.Routing, error)

GetRouting returns a routing

func (*EtcdStore) GetRoutings

func (e *EtcdStore) GetRoutings(limit int64, fn func(interface{}) error) error

GetRoutings returns routes in store

func (*EtcdStore) GetServer

func (e *EtcdStore) GetServer(id uint64) (*metapb.Server, error)

GetServer returns the server

func (*EtcdStore) GetServers

func (e *EtcdStore) GetServers(limit int64, fn func(interface{}) error) error

GetServers returns all server

func (*EtcdStore) PutAPI

func (e *EtcdStore) PutAPI(value *metapb.API) (uint64, error)

PutAPI add or update a API

func (*EtcdStore) PutCluster

func (e *EtcdStore) PutCluster(value *metapb.Cluster) (uint64, error)

PutCluster add or update the cluster

func (*EtcdStore) PutRouting

func (e *EtcdStore) PutRouting(value *metapb.Routing) (uint64, error)

PutRouting add or update routing

func (*EtcdStore) PutServer

func (e *EtcdStore) PutServer(value *metapb.Server) (uint64, error)

PutServer add or update the server

func (*EtcdStore) Raw

func (e *EtcdStore) Raw() interface{}

Raw returns the raw client

func (*EtcdStore) RegistryProxy

func (e *EtcdStore) RegistryProxy(proxy *metapb.Proxy, ttl int64) error

RegistryProxy registry

func (*EtcdStore) RemoveAPI

func (e *EtcdStore) RemoveAPI(id uint64) error

RemoveAPI remove a api from store

func (*EtcdStore) RemoveBind

func (e *EtcdStore) RemoveBind(bind *metapb.Bind) error

RemoveBind remove bind

func (*EtcdStore) RemoveCluster

func (e *EtcdStore) RemoveCluster(id uint64) error

RemoveCluster remove the cluster and it's binds

func (*EtcdStore) RemoveClusterBind

func (e *EtcdStore) RemoveClusterBind(id uint64) error

RemoveClusterBind remove cluster all bind servers

func (*EtcdStore) RemoveRouting

func (e *EtcdStore) RemoveRouting(id uint64) error

RemoveRouting remove routing

func (*EtcdStore) RemoveServer

func (e *EtcdStore) RemoveServer(id uint64) error

RemoveServer remove the server

func (*EtcdStore) Watch

func (e *EtcdStore) Watch(evtCh chan *Evt, stopCh chan bool) error

Watch watch event from etcd

type Evt

type Evt struct {
	Src   EvtSrc
	Type  EvtType
	Key   string
	Value interface{}
}

Evt event

type EvtSrc

type EvtSrc int

EvtSrc event src

type EvtType

type EvtType int

EvtType event type

type Store

type Store interface {
	Raw() interface{}

	AddBind(bind *metapb.Bind) error
	RemoveBind(bind *metapb.Bind) error
	RemoveClusterBind(id uint64) error
	GetBindServers(id uint64) ([]uint64, error)

	PutCluster(cluster *metapb.Cluster) (uint64, error)
	RemoveCluster(id uint64) error
	GetClusters(limit int64, fn func(interface{}) error) error
	GetCluster(id uint64) (*metapb.Cluster, error)

	PutServer(svr *metapb.Server) (uint64, error)
	RemoveServer(id uint64) error
	GetServers(limit int64, fn func(interface{}) error) error
	GetServer(id uint64) (*metapb.Server, error)

	PutAPI(api *metapb.API) (uint64, error)
	RemoveAPI(id uint64) error
	GetAPIs(limit int64, fn func(interface{}) error) error
	GetAPI(id uint64) (*metapb.API, error)

	PutRouting(routing *metapb.Routing) (uint64, error)
	RemoveRouting(id uint64) error
	GetRoutings(limit int64, fn func(interface{}) error) error
	GetRouting(id uint64) (*metapb.Routing, error)

	RegistryProxy(proxy *metapb.Proxy, ttl int64) error
	GetProxies(limit int64, fn func(*metapb.Proxy) error) error

	Watch(evtCh chan *Evt, stopCh chan bool) error

	Clean() error
}

Store store interface

func GetStoreFrom

func GetStoreFrom(registryAddr, prefix string) (Store, error)

GetStoreFrom returns a store implemention, if not support returns error

func NewEtcdStore

func NewEtcdStore(etcdAddrs []string, prefix string) (Store, error)

NewEtcdStore create a etcd store

Jump to

Keyboard shortcuts

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