rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegistryTypeMDNS            = "mdns"
	RegistryTypeConsul          = "consul"
	RegistryTypeRedis           = "redis"
	RegistryTypeEtcdV3          = "etcdv3"
	RegistryTypePeer2Peer       = "peer2peer"
	RegistryTypeMultipleServers = "multipleservers"
)

Variables

View Source
var (
	ErrorUnsupportedRegistryType = errors.New("unsupported registry type")
	ErrorAddress                 = errors.New("address error")
)
View Source
var (
	ErrorSerivceNotExists = errors.New("service not exists")
)
View Source
var (
	ErrorServerClosed = errors.New("server closed")
)

Functions

func GetRemoteAddr

func GetRemoteAddr(ctx *share.Context) string

func GetRequestValue

func GetRequestValue(ctx *share.Context, key string) string

func GetResponseValue

func GetResponseValue(ctx *share.Context, key string) string

func SetLogger

func SetLogger(l log.Logger)

func SetRequestValue

func SetRequestValue(ctx *share.Context, key string, value string)

func SetResponseValue

func SetResponseValue(ctx *share.Context, key string, value string)

Types

type ClientManager

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

func NewServiceManager

func NewServiceManager(cfg *ClientManagerConfig) (*ClientManager, error)

func (*ClientManager) AddService

func (m *ClientManager) AddService(name, servicePath string) error

func (*ClientManager) Close

func (m *ClientManager) Close(c *client.XClientPool) error

func (*ClientManager) GetClient

func (m *ClientManager) GetClient(name string) (client.XClient, error)

func (*ClientManager) GetServices

func (m *ClientManager) GetServices(name string) map[string]string

func (*ClientManager) Release

func (m *ClientManager) Release() error

func (*ClientManager) SetClientFailMode

func (m *ClientManager) SetClientFailMode(name string, mode client.FailMode)

func (*ClientManager) SetClientOption

func (m *ClientManager) SetClientOption(name string, option client.Option)

func (*ClientManager) SetClientSelectMode

func (m *ClientManager) SetClientSelectMode(name string, mode client.SelectMode)

type ClientManagerConfig

type ClientManagerConfig struct {
	Type      string
	Endpoints string
	BasePath  string

	MaxConnsPerService int

	CircuitBreakerFailureThreshold uint64
	CircuitBreakerRestoreWindow    time.Duration
}

type Server

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

func New

func New(cfg *ServerConfig, plugins ...server.Plugin) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) RegisterFileTransferService

func (s *Server) RegisterFileTransferService(name string, addr string, handler server.FileTransferHandler, downloadFileHandler server.DownloadFileHandler, waitNum int) error

func (*Server) RegisterService

func (s *Server) RegisterService(name string, obj interface{}) error

func (*Server) RegisterStreamService

func (s *Server) RegisterStreamService(name string, addr string, streamHandler server.StreamHandler, acceptor server.StreamAcceptor, waitNum int) error

func (*Server) Run

func (s *Server) Run() error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type ServerConfig

type ServerConfig struct {
	Address string

	// registry
	RegistryType      string
	RegistryEndpoints string
	RegistryInterval  time.Duration
	RegistryBasePath  string

	// rate limiting
	RateLimitingConnectFillInterval time.Duration
	RateLimitingConnectCapacity     int64
	RateLimitingRequestFillInterval time.Duration
	RateLimitingRequestCapacity     int64
}

type Service

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

Jump to

Keyboard shortcuts

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