router

package
v0.0.0-...-856de4a Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

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

func NewHost

func NewHost(conf *config.Config) (*Host, error)

func (*Host) RPCHeartbeat

func (h *Host) RPCHeartbeat(_ context.Context, in *rpcapi.Ping) (*rpcapi.Empty, error)

func (*Host) RPCRegister

func (h *Host) RPCRegister(ctx context.Context, in *rpcapi.NodeMeta) (*rpcapi.Empty, error)

func (*Host) RunHTTPServer

func (h *Host) RunHTTPServer(addr string) error

type Middleware

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

Middleware - middleware template

func LatencyMiddleware

func LatencyMiddleware(h http.Handler, wait time.Duration) *Middleware

LatencyMiddleware - simulates node latency

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Router

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

Router represents bounding of network api with kvrouter lib and local node

func (*Router) AddData

func (h *Router) AddData(cID uint64, di balancer.DataItem) error

func (*Router) AddNode

func (h *Router) AddNode(ctx context.Context, n nodes.Node) error

AddNode adds node to kvrouter

func (*Router) CallOptimize

func (h *Router) CallOptimize(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*Router) Cid

func (*Router) Config

func (h *Router) Config(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

func (*Router) Explore

func (h *Router) Explore(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Explore returns a list of keys on nodes

func (*Router) GetNode

func (h *Router) GetNode(id string) (nodes.Node, error)

GetNode returns the node with the given ID

func (*Router) GetNodes

func (h *Router) GetNodes() ([]nodes.Node, error)

GetNodes - returns a list of nodes in the balancer

func (*Router) HTTPHandler

func (h *Router) HTTPHandler() *httprouter.Router

func (*Router) Hasher

func (h *Router) Hasher() nodehasher.Hasher

func (*Router) LocateKey

func (h *Router) LocateKey(rdi *rpcapi.DataItem) (nodes.Node, uint64, error)

Returns node from kvrouter by given key.

func (*Router) Nodes

func (h *Router) Nodes(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Nodes returns a list of nodes

func (*Router) Optimize

func (h *Router) Optimize(ctx context.Context) error

func (*Router) Receive

func (h *Router) Receive(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

Receive value for a given key from the remote node

func (*Router) RemoveData

func (h *Router) RemoveData(key string) error

func (*Router) RemoveNode

func (h *Router) RemoveNode(id string) error

RemoveNode removes node from kvrouter

func (*Router) SetNodes

func (h *Router) SetNodes(ns []nodes.Node) error

SetNodes - removes all nodes from the balancer and set a new ones

func (*Router) Store

func (h *Router) Store(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

Store value for a given key on the remote node

type SyncMap

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

func NewSyncMap

func NewSyncMap() *SyncMap

func (*SyncMap) Append

func (sm *SyncMap) Append(key string, value string)

func (*SyncMap) Copy

func (sm *SyncMap) Copy() map[string][]string

func (*SyncMap) Delete

func (sm *SyncMap) Delete(key string)

func (*SyncMap) Get

func (sm *SyncMap) Get(key string) ([]string, bool)

func (*SyncMap) JsonMarshal

func (sm *SyncMap) JsonMarshal() ([]byte, error)

func (*SyncMap) Put

func (sm *SyncMap) Put(key string, value []string)

Directories

Path Synopsis
package provides adapter interface for balancing mechanism.
package provides adapter interface for balancing mechanism.

Jump to

Keyboard shortcuts

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