api

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MPL-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RPCGob byte = iota
	RPCJson
)

Variables

This section is empty.

Functions

func NewClient

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

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

func NewJsonClientCodec

func NewJsonClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

json client

func NewJsonServerCodec

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

type Client interface {
	Services(serviceName string, state StateType) Service
	Random(url string) (string, error)
	RoundRobin(url string) (string, error)
	Hash(key, url string) (string, error)
	ConsistentHash(key, url string) (string, error)
}

func RiffClient

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

func CmdType_FromName(name string) CmdType

func (CmdType) Name

func (c CmdType) Name() string

func (CmdType) Value

func (c CmdType) Value() int

type HashKey

type HashKey uint32

type HashKeyOrder

type HashKeyOrder []HashKey

func (HashKeyOrder) Len

func (h HashKeyOrder) Len() int

func (HashKeyOrder) Less

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

func (HashKeyOrder) Swap

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

type HttpClient

type HttpClient struct {
	Url string
}

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

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 RpcClient

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

func (*RpcClient) ConsistentHash added in v0.0.27

func (s *RpcClient) ConsistentHash(key, url string) (string, error)

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

func (*RpcClient) Hash

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

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

func (*RpcClient) Random added in v0.0.27

func (s *RpcClient) Random(url string) (string, error)

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

func (*RpcClient) RoundRobin added in v0.0.27

func (s *RpcClient) RoundRobin(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

func (s *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

func StateType_FromName(name string) StateType

func (StateType) Name

func (s StateType) Name() string

func (StateType) Value

func (s StateType) Value() int

Jump to

Keyboard shortcuts

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