api

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient added in v0.0.2

func NewClient(address string) (*rpc.Client, error)

func NewGobClientCodec

func NewGobClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

client

func NewGobServerCodec

func NewGobServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec

server

func NewJsonClient added in v0.0.2

func NewJsonClient(address string) (*rpc.Client, error)

func NewJsonClientCodec added in v0.0.2

func NewJsonClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

json client

func NewJsonServerCodec added in v0.0.2

func NewJsonServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec

json server

func TimeoutCoder

func TimeoutCoder(f func(interface{}) error, e interface{}, msg string) error

Types

type Client added in v0.0.8

type Client interface {
	Services(serviceName string, state StateType) Service
	Robin(url string) (string, error)
	Round(url string) (string, error)
	Hash(url, key string) (string, error)
	HashRing(url, key string) (string, error)
}

func RiffClient added in v0.0.8

func RiffClient(url string) (Client, error)

url : riff://ip:port return Client

type CmdType

type CmdType int
const (
	CmdStart CmdType = 1 << iota
	CmdStop
	CmdRestart
)

func CmdType_FromName added in v0.0.5

func CmdType_FromName(name string) CmdType

func (CmdType) Name added in v0.0.5

func (c CmdType) Name() string

func (CmdType) Value added in v0.0.5

func (c CmdType) Value() int

type HashKey added in v0.0.8

type HashKey uint32

type HashKeyOrder added in v0.0.8

type HashKeyOrder []HashKey

func (HashKeyOrder) Len added in v0.0.8

func (h HashKeyOrder) Len() int

func (HashKeyOrder) Less added in v0.0.8

func (h HashKeyOrder) Less(i, j int) bool

func (HashKeyOrder) Swap added in v0.0.8

func (h HashKeyOrder) Swap(i, j int)

type HashRing added in v0.0.8

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

func New added in v0.0.8

func New(nodes []string) *HashRing

func NewWithWeights added in v0.0.8

func NewWithWeights(weights map[string]int) *HashRing

func (*HashRing) AddNode added in v0.0.8

func (h *HashRing) AddNode(node string) *HashRing

func (*HashRing) AddWeightedNode added in v0.0.8

func (h *HashRing) AddWeightedNode(node string, weight int) *HashRing

func (*HashRing) GenKey added in v0.0.8

func (h *HashRing) GenKey(key string) HashKey

func (*HashRing) GetNode added in v0.0.8

func (h *HashRing) GetNode(stringKey string) (node string, ok bool)

func (*HashRing) GetNodePos added in v0.0.8

func (h *HashRing) GetNodePos(stringKey string) (pos int, ok bool)

func (*HashRing) GetNodes added in v0.0.8

func (h *HashRing) GetNodes(stringKey string, size int) (nodes []string, ok bool)

func (*HashRing) RemoveNode added in v0.0.8

func (h *HashRing) RemoveNode(node string) *HashRing

func (*HashRing) Size added in v0.0.8

func (h *HashRing) Size() int

func (*HashRing) UpdateWeightedNode added in v0.0.8

func (h *HashRing) UpdateWeightedNode(node string, weight int) *HashRing

func (*HashRing) UpdateWithWeights added in v0.0.8

func (h *HashRing) UpdateWithWeights(weights map[string]int)

type HttpClient added in v0.0.8

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

todo

type NestNode

type NestNode struct {
	Name          string        `json:"name"`
	DataCenter    string        `json:"dataCenter"`
	IP            string        `json:"ip"`
	Port          int           `json:"port,omitempty"`
	RpcPort       int           `json:"rpcPort,omitempty"`
	Version       int           `json:"version"`
	State         StateType     `json:"state"`
	SnapShot      string        `json:"snapShot,omitempty"`
	IsSelf        bool          `json:"isSelf,omitempty"`
	Config        string        `json:"config,omitempty"`
	StatusContent string        `json:"statusContent,omitempty"`
	StartTime     time.Time     `json:"startTime,omitempty"`
	Progress      *NestProgress `json:"progress,omitempty"`
}

type NestNodes

type NestNodes []*NestNode

type NestProgress added in v0.0.9

type NestProgress struct {
	Current    int32 `json:"current,omitempty"`
	Total      int32 `json:"total,omitempty"`
	InProgress bool  `json:"inProgress,omitempty"`
}

type NestService

type NestService struct {
	Name          string        `json:"name"`
	IP            string        `json:"ip"`
	Port          int           `json:"port,omitempty"`
	State         StateType     `json:"state,omitempty"`
	Config        string        `json:"config,omitempty"`
	StatusContent string        `json:"statusContent,omitempty"`
	StartTime     time.Time     `json:"startTime,omitempty"`
	Progress      *NestProgress `json:"progress,omitempty"`
}

type NestServices

type NestServices []*NestService

type Node

type Node struct {
	Name         string    `json:"name"`
	DataCenter   string    `json:"dataCenter"`
	IP           string    `json:"ip"`
	RpcPort      int       `json:"rpcPort,omitempty"`
	HttpPort     int       `json:"httpPort,omitempty"`
	Version      int       `json:"version"`
	State        StateType `json:"state"`
	SnapShot     string    `json:"snapShot,omitempty"`
	IsSelf       bool      `json:"isSelf,omitempty"`
	NestServices `json:"services,omitempty"`
}

type Nodes

type Nodes []*Node

type ParamNode

type ParamNode struct {
	Name string `json:"name"`
}

type ParamService

type ParamService struct {
	Name  string    `json:"name"`
	State StateType `json:"state,omitempty"`
}

type ParamServiceMutation

type ParamServiceMutation struct {
	Name string  `json:"name"`
	Cmd  CmdType `json:"cmd,omitempty"`
}

type Progress added in v0.0.9

type Progress func(int32, int32)

type RPCType added in v0.0.2

type RPCType byte
const (
	RPCGob  RPCType = 0
	RPCJson         = 1
)

type RpcClient added in v0.0.8

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

func (*RpcClient) Hash added in v0.0.8

func (this *RpcClient) Hash(url, key string) (string, error)

hash url: http://serviceName or rpc://serviceName http url return http://ip:port rpc url only return ip:port

func (*RpcClient) HashRing added in v0.0.8

func (this *RpcClient) HashRing(url, key string) (string, error)

hashring url: http://serviceName or rpc://serviceName http url return http://ip:port rpc url only return ip:port

func (*RpcClient) Robin added in v0.0.8

func (this *RpcClient) Robin(url string) (string, error)

robin url: http://serviceName or rpc://serviceName http url return http://ip:port rpc url only return ip:port

func (*RpcClient) Round added in v0.0.8

func (this *RpcClient) Round(url string) (string, error)

round url: http://serviceName or rpc://serviceName http url return http://ip:port rpc url only return ip:port

func (*RpcClient) Services added in v0.0.8

func (this *RpcClient) Services(name string, state StateType) (service Service)

type Service

type Service struct {
	Name      string `json:"name"`
	NestNodes `json:"nodes,omitempty"`
}

type Services

type Services []*Service

type StateType

type StateType int
const (
	StateAlive StateType = 1 << iota
	StateSuspect
	StateDead
	StateAll = StateAlive | StateSuspect | StateDead
)

func StateType_FromName added in v0.0.5

func StateType_FromName(name string) StateType

func (StateType) Name added in v0.0.5

func (s StateType) Name() string

func (StateType) Value added in v0.0.5

func (s StateType) Value() int

Jump to

Keyboard shortcuts

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