baserpc

package
v0.0.0-...-6c6cd66 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientError           = -1000
	ClientParamNotAdapted = -1
	ClientFormatError     = -2
	//ClientSuccess = -3
	//client independence
	ClientUnAuthenticated = -100

	ServerError       = 1000
	ServerParamMiss   = -ClientParamNotAdapted
	ServerFormatError = -ClientFormatError
	//ServerSuccess = -ClientSuccess
	//server independence
	ServerDBError        = 100
	ServerRpcInvokeError = 101
	ServerExpired        = 102
)

Variables

View Source
var (
	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrClientParamsMiss = &Error{Code: ClientParamNotAdapted, Reason: "client miss some params to invoke rpc"}

	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrClientFormatError = &Error{Code: ClientFormatError, Reason: "client params format error"}

	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrClientUnAuthenticated = &Error{Code: ClientUnAuthenticated, Reason: "client is unauthenticated"}

	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrServerParamMiss = &Error{Code: ServerParamMiss, Reason: "server miss some params to invoke rpc"}

	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrServerFormatError = &Error{Code: ServerFormatError, Reason: "server params format error"}

	// ErrParamsMiss is returned when client miss some params to invoke rpc
	ErrServerDBError = &Error{Code: ServerDBError, Reason: "server db error"}
)
View Source
var (
	TypeServer = 0
	TypeClient = 1
)

Functions

func NewAMQPClient

func NewAMQPClient(info *conf.Rabbitmq) (client *amqpClient, err error)

func NewAMQPServer

func NewAMQPServer(info *conf.Rabbitmq, call_chan chan rpc.CallInfo) (*amqpServer, error)

func NewLocalClient

func NewLocalClient(server rpc.LocalServer) (*localClient, error)

这里是暴露整个Local server还是只暴露local server的mq_chan呢 因为是本地,暂时暴露整个local server也是OK的

func NewLocalServer

func NewLocalServer(call_chan chan rpc.CallInfo) (*localServer, error)

func NewRPCClient

func NewRPCClient(app module.AppInterface, serverId string) (rpc.RPCClient, error)

func NewRPCServer

func NewRPCServer(app module.AppInterface, module module.Module) (rpc.RPCServer, error)

func NewRedisClient

func NewRedisClient(info *conf.Redis) (client *redisClient, err error)

func NewRedisServer

func NewRedisServer(info *conf.Redis, call_chan chan rpc.CallInfo) (*redisServer, error)

Types

type ClientCallInfo

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

type Error

type Error struct {
	Code   int    // constant code from the specification
	Reason string // description of the error

}

Error captures the code and reason a channel or connection has been closed by the server.

func NewError

func NewError(code int, err interface{}) *Error

func (Error) Error

func (e Error) Error() string

type RPCServer

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

func (*RPCServer) Done

func (s *RPCServer) Done() (err error)

need check

func (*RPCServer) Finish

func (this *RPCServer) Finish()

func (*RPCServer) GetExecuting

func (s *RPCServer) GetExecuting() int64

func (*RPCServer) GetLocalRpcServer

func (s *RPCServer) GetLocalRpcServer() rpc.LocalServer

func (*RPCServer) NewRabbitmqRpcServer

func (s *RPCServer) NewRabbitmqRpcServer(info *conf.Rabbitmq) (err error)

create remote rpc service

func (*RPCServer) NewRedisRpcServer

func (s *RPCServer) NewRedisRpcServer(info *conf.Redis) (err error)

create redis rpc service

func (*RPCServer) Register

func (s *RPCServer) Register(id string, fn interface{})

func (*RPCServer) RegisterGo

func (s *RPCServer) RegisterGo(id string, fn interface{})

func (*RPCServer) SetGoroutineControl

func (s *RPCServer) SetGoroutineControl(control rpc.GoroutineControl)

func (*RPCServer) SetListener

func (s *RPCServer) SetListener(listener rpc.RPCListener)

func (*RPCServer) Wait

func (this *RPCServer) Wait() error

type RabbitAgent

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

func NewRabbitAgent

func NewRabbitAgent(info *conf.Rabbitmq, serverType int) (*RabbitAgent, error)

func (*RabbitAgent) CallbackQueue

func (this *RabbitAgent) CallbackQueue() (string, error)

* 创建回调 提供给 rpc client调用

func (*RabbitAgent) ClientPublish

func (this *RabbitAgent) ClientPublish(body []byte) error

* rpc client写数据

func (*RabbitAgent) Closed

func (this *RabbitAgent) Closed() bool

func (*RabbitAgent) ExchangeDeclare

func (this *RabbitAgent) ExchangeDeclare() error

* 声明一个交换器,提供给rpc server端调用

func (*RabbitAgent) Queue

func (this *RabbitAgent) Queue() error

* 创建回调 提供给 rpc server调用

func (*RabbitAgent) RChannel

func (this *RabbitAgent) RChannel() (*amqp.Channel, error)

* 获取读通道

func (*RabbitAgent) RConnect

func (this *RabbitAgent) RConnect() error

* 创建一个读连接

func (*RabbitAgent) ReadMsg

func (this *RabbitAgent) ReadMsg() chan amqp.Delivery

func (*RabbitAgent) ServerPublish

func (this *RabbitAgent) ServerPublish(queueName string, body []byte) error

* rpc server写数据

func (*RabbitAgent) Shutdown

func (this *RabbitAgent) Shutdown() error

* 停止服务

func (*RabbitAgent) WChannel

func (this *RabbitAgent) WChannel() (*amqp.Channel, error)

* 获取写通道

func (*RabbitAgent) WConnect

func (this *RabbitAgent) WConnect() error

* 创建一个写连接

Jump to

Keyboard shortcuts

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