handler

package
v0.0.0-...-4ac4421 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_WORKER_EXISTS     = errors.New("ERR_WORKER_EXISTS")
	ERR_WORKER_NOT_EXISTS = errors.New("ERR_WORKER_NOT_EXISTS")
)

Functions

func AddWorker

func AddWorker(w Worker) error

func ListWorkers

func ListWorkers() map[string][]string

ListWorkers ListWorkers

func NewService

func NewService(confPath string) (*service, error)

func RegisterHandler

func RegisterHandler(s *service)

RegisterHandler Register handlers

func RemoveWorker

func RemoveWorker(w Worker) error

func RemoveWorkerAsTimeout

func RemoveWorkerAsTimeout()

RemoveWorkerAsTimeout remove those workers lost heartbeat

func SetLBPolicy

func SetLBPolicy(p util.LBPolicyEnum)

Types

type Comparable

type Comparable interface {
	IsEqual(a interface{}) bool
}

type DefaultServiceRegCommand

type DefaultServiceRegCommand struct {
	UriPath        string
	Host           string
	HealthCheckURL string
}

func (*DefaultServiceRegCommand) Apply

func (c *DefaultServiceRegCommand) Apply(server raft.Server) (interface{}, error)

func (*DefaultServiceRegCommand) CommandName

func (c *DefaultServiceRegCommand) CommandName() string

type DefaultServiceRmCommand

type DefaultServiceRmCommand struct {
	UriPath string
	Host    string
}

func (*DefaultServiceRmCommand) Apply

func (c *DefaultServiceRmCommand) Apply(server raft.Server) (interface{}, error)

func (*DefaultServiceRmCommand) CommandName

func (c *DefaultServiceRmCommand) CommandName() string

type ProcTimer

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

func (*ProcTimer) Duration

func (w *ProcTimer) Duration() int

func (*ProcTimer) OnEnd

func (w *ProcTimer) OnEnd()

func (*ProcTimer) OnStart

func (w *ProcTimer) OnStart()

type Service

type Service interface {
	Add(string, string) error
	Remove(string, string) error
}

type ServiceCommand

type ServiceCommand interface {
	raft.Command
	Data() interface{}
}

type Worker

type Worker struct {
	HealthCheckURL string // api for healthcheck
	Heartbeat      int64  // last heartbeat timestamp
	UriPath        string // api request uripath
	Host           string

	sync.Mutex
	// contains filtered or unexported fields
}

func FastResponseWorker

func FastResponseWorker(uripath string) (*Worker, error)

func GetWorker

func GetWorker(uripath string) (*Worker, error)

func NewWorker

func NewWorker() *Worker

func RandomWorker

func RandomWorker(uripath string) (*Worker, error)

func RoundRobinWorker

func RoundRobinWorker(uripath string) (*Worker, error)

func (*Worker) AsTaskFinished

func (w *Worker) AsTaskFinished(timeUsed int)

func (*Worker) AsyncHealthCheck

func (worker *Worker) AsyncHealthCheck()

AsyncHealthCheck helthcheck for one node

func (*Worker) CallCount

func (w *Worker) CallCount() int

func (*Worker) HostToCall

func (w *Worker) HostToCall() string

get host to call, and do something extra

func (*Worker) IsEqual

func (w *Worker) IsEqual(nw interface{}) bool

func (*Worker) ResponseTimeUsed

func (w *Worker) ResponseTimeUsed() int

type Workers

type Workers struct {
	Members map[string][]Worker

	sync.Mutex
	// contains filtered or unexported fields
}

func NewWorkers

func NewWorkers() *Workers

func (*Workers) AsyncHealthCheck

func (workers *Workers) AsyncHealthCheck()

AsyncHealthCheck check works with heartbeat

Jump to

Keyboard shortcuts

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