cgrpc

package
v0.0.0-...-6451425 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGameEtcdWatcher

func NewGameEtcdWatcher(scheme string) *etcdWatcher

Types

type Client

type Client struct {
	Namespace   string
	DialBalance string // default:round_robin
	ClientConn  *grpc.ClientConn
	// contains filtered or unexported fields
}

common balance cluster the balance was desided by grpc

func NewClient

func NewClient(assignment option.Assignment) *Client

func (*Client) Close

func (self *Client) Close()

func (*Client) Dial

func (self *Client) Dial(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

as same as grpc.Dial.

func (*Client) DialUrl

func (self *Client) DialUrl(urls ...string) string

func (*Client) Start

func (self *Client) Start()

you should run it with go command.

func (*Client) Wait

func (self *Client) Wait()

type Config

type Config struct {
	PathName   string
	Addr       string
	ListenAddr string
	TTL        int64
	Namespace  string
}

contain configration of grpc listened and etcd paramters.

type GameClientClusterInterface

type GameClientClusterInterface interface {
	UpdateState([]*ServInfo) error
}

type GameGrpcConn

type GameGrpcConn struct {
	*grpc.ClientConn
	Info ServInfo
}

func (*GameGrpcConn) Close

func (self *GameGrpcConn) Close()

func (*GameGrpcConn) Dial

func (self *GameGrpcConn) Dial(target string, opts ...grpc.DialOption) error

func (*GameGrpcConn) GetState

func (self *GameGrpcConn) GetState() connectivity.State

type GameRpcCluster

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

func NewGameGrpcCluster

func NewGameGrpcCluster(assignment option.Assignment) *GameRpcCluster

func (*GameRpcCluster) Close

func (self *GameRpcCluster) Close()

func (*GameRpcCluster) GetGameClientConns

func (self *GameRpcCluster) GetGameClientConns() []*GameGrpcConn

func (*GameRpcCluster) Handle

func (self *GameRpcCluster) Handle(fn func(gconns []*GameGrpcConn))

func (*GameRpcCluster) Register

func (self *GameRpcCluster) Register(whatcher WatchInterface)

func (*GameRpcCluster) ResolveNow

func (self *GameRpcCluster) ResolveNow()

func (*GameRpcCluster) Start

func (self *GameRpcCluster) Start()

func (*GameRpcCluster) UpdateState

func (self *GameRpcCluster) UpdateState(servInfos []*ServInfo) error

func (*GameRpcCluster) Wait

func (self *GameRpcCluster) Wait()

type Resolver

type Resolver interface {
	GameClientClusterInterface
}

type ServInfo

type ServInfo struct {
	AddrToRpc    string
	AddrToClient string
	Name         string
	// contains filtered or unexported fields
}

func NewServInfo

func NewServInfo(infos []string) *ServInfo

func (*ServInfo) Set

func (self *ServInfo) Set(data any)

func (*ServInfo) Value

func (self *ServInfo) Value() any

type Server

type Server struct {
	ID string

	Addr string

	AddrToClient string
	TTL          int64
	Namespace    string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(assignment option.Assignment) *Server

func (*Server) Delete

func (self *Server) Delete()

func (*Server) GetID

func (self *Server) GetID() string

func (*Server) RegisterService

func (self *Server) RegisterService(caller func(server *grpc.Server))

func (*Server) Serv

func (self *Server) Serv(opts ...grpc.ServerOption)

suitable grpc option configration

func (*Server) Wait

func (self *Server) Wait()

type WatchInterface

type WatchInterface interface {
	Scheme() string
	Watch(target resolver.Target, cc GameClientClusterInterface, assignment option.Assignment) (Resolver, error)
}

Jump to

Keyboard shortcuts

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