router

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckService

func CheckService(srv string) (string, []string, error)

func Handler

func Handler(r UpdatableRouter) http.Handler

func UpdateRouter

func UpdateRouter(r UpdatableRouter, srv string) error

Types

type HTTPData

type HTTPData struct {
	Self  string
	Nodes []string
}

type Router

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

func New

func New(self string) *Router

func (*Router) GetHostByKey

func (r *Router) GetHostByKey(key string) string

func (*Router) IsSelf

func (r *Router) IsSelf(node string) bool

func (*Router) Nodes

func (r *Router) Nodes() []string

func (*Router) SetNodes

func (r *Router) SetNodes(nodes []string)

type StaticRouter

type StaticRouter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

StaticRouter keeps routing table: which node is responsible for which account

func NewStatic

func NewStatic(self string) *StaticRouter

func (*StaticRouter) GetHostByKey

func (r *StaticRouter) GetHostByKey(key string) string

GetHostByKey returns host for given key. Key is usually accountID

func (*StaticRouter) IsSelf

func (r *StaticRouter) IsSelf(node string) bool

IsSelf checks if current node is equal to given

func (*StaticRouter) Nodes

func (r *StaticRouter) Nodes() []string

func (*StaticRouter) Self

func (r *StaticRouter) Self() string

func (*StaticRouter) SetNodes

func (r *StaticRouter) SetNodes(shardNodes []string)

func (*StaticRouter) SetSelf

func (r *StaticRouter) SetSelf(s string)

type UpdatableRouter

type UpdatableRouter interface {
	Nodes() []string
	SetNodes([]string)

	Self() string
	SetSelf(string)
}

Jump to

Keyboard shortcuts

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