defaultrpc

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: Apache-2.0 Imports: 18 Imported by: 24

Documentation

Overview

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 mqant Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeServer = 0
	TypeClient = 1
)

Functions

func NewRPCClient

func NewRPCClient(app module.App, serverId string) (mqrpc.RPCClient, error)

func NewRPCServer

func NewRPCServer(app module.App, module module.Module) (mqrpc.RPCServer, error)

Types

type AMQPClient added in v1.6.7

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

func NewAMQPClient added in v1.6.7

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

func (*AMQPClient) Call added in v1.6.7

func (c *AMQPClient) Call(callInfo mqrpc.CallInfo, callback chan rpcpb.ResultInfo) error

* 消息请求

func (*AMQPClient) CallNR added in v1.6.7

func (c *AMQPClient) CallNR(callInfo mqrpc.CallInfo) error

* 消息请求 不需要回复

func (*AMQPClient) Done added in v1.6.7

func (c *AMQPClient) Done() (err error)

func (*AMQPClient) Marshal added in v1.6.7

func (c *AMQPClient) Marshal(rpcInfo *rpcpb.RPCInfo) ([]byte, error)

goroutine safe

func (*AMQPClient) Unmarshal added in v1.6.7

func (c *AMQPClient) Unmarshal(data []byte) (*rpcpb.RPCInfo, error)

func (*AMQPClient) UnmarshalResult added in v1.6.7

func (c *AMQPClient) UnmarshalResult(data []byte) (*rpcpb.ResultInfo, error)

type AMQPServer added in v1.6.7

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

func NewAMQPServer added in v1.6.7

func NewAMQPServer(info *conf.Rabbitmq, call_chan chan mqrpc.CallInfo) (*AMQPServer, error)

func (*AMQPServer) Callback added in v1.6.7

func (s *AMQPServer) Callback(callinfo mqrpc.CallInfo) error

func (*AMQPServer) MarshalResult added in v1.6.7

func (s *AMQPServer) MarshalResult(resultInfo rpcpb.ResultInfo) ([]byte, error)

goroutine safe

func (*AMQPServer) Shutdown added in v1.6.7

func (s *AMQPServer) Shutdown() error

* 注销消息队列

func (*AMQPServer) StopConsume added in v1.6.7

func (s *AMQPServer) StopConsume() error

* 停止接收请求

func (*AMQPServer) Unmarshal added in v1.6.7

func (s *AMQPServer) Unmarshal(data []byte) (*rpcpb.RPCInfo, error)

type ClinetCallInfo

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

type Consumer added in v1.6.7

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

func NewConsumer added in v1.6.7

func NewConsumer(info *conf.Rabbitmq, amqpURI, exchange, exchangeType, ctag string) (*Consumer, error)

func (*Consumer) Cancel added in v1.6.7

func (c *Consumer) Cancel() error

func (*Consumer) Shutdown added in v1.6.7

func (c *Consumer) Shutdown() error

type LocalClient added in v1.6.7

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

func NewLocalClient added in v1.6.7

func NewLocalClient(server mqrpc.LocalServer) (*LocalClient, error)

func (*LocalClient) Call added in v1.6.7

func (c *LocalClient) Call(callInfo mqrpc.CallInfo, callback chan rpcpb.ResultInfo) (err error)

* 消息请求

func (*LocalClient) CallNR added in v1.6.7

func (c *LocalClient) CallNR(callInfo mqrpc.CallInfo) (err error)

* 消息请求 不需要回复

func (*LocalClient) Done added in v1.6.7

func (c *LocalClient) Done() error

type LocalServer added in v1.6.7

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

func NewLocalServer added in v1.6.7

func NewLocalServer(call_chan chan mqrpc.CallInfo) (*LocalServer, error)

func (*LocalServer) Callback added in v1.6.7

func (s *LocalServer) Callback(callinfo mqrpc.CallInfo) error

*

func (*LocalServer) IsClose added in v1.6.7

func (s *LocalServer) IsClose() bool

* 停止接收请求

func (*LocalServer) SafeCallback added in v1.6.7

func (s *LocalServer) SafeCallback(local_chan chan rpcpb.ResultInfo, callInfo rpcpb.ResultInfo) (closed bool)

func (*LocalServer) SafeSend added in v1.6.7

func (s *LocalServer) SafeSend(local_chan chan mqrpc.CallInfo, callInfo mqrpc.CallInfo) (closed bool)

func (*LocalServer) Shutdown added in v1.6.7

func (s *LocalServer) Shutdown() (err error)

* 注销消息队列

func (*LocalServer) StopConsume added in v1.6.7

func (s *LocalServer) StopConsume() error

* 停止接收请求

func (*LocalServer) Write added in v1.6.7

func (s *LocalServer) Write(callInfo mqrpc.CallInfo) error

* 停止接收请求

type RPCClient

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

func (*RPCClient) Call

func (c *RPCClient) Call(_func string, params ...interface{}) (interface{}, string)

* 消息请求 需要回复

func (*RPCClient) CallArgs

func (c *RPCClient) CallArgs(_func string, ArgsType []string, args [][]byte) (interface{}, string)

func (*RPCClient) CallNR

func (c *RPCClient) CallNR(_func string, params ...interface{}) (err error)

* 消息请求 不需要回复

func (*RPCClient) CallNRArgs

func (c *RPCClient) CallNRArgs(_func string, ArgsType []string, args [][]byte) (err error)

func (*RPCClient) Done

func (c *RPCClient) Done() (err error)

func (*RPCClient) NewLocalClient added in v1.6.7

func (c *RPCClient) NewLocalClient(server mqrpc.RPCServer) (err error)

func (*RPCClient) NewRabbitmqClient added in v1.6.7

func (c *RPCClient) NewRabbitmqClient(info *conf.Rabbitmq) (err error)

func (*RPCClient) NewRedisClient added in v1.6.7

func (c *RPCClient) NewRedisClient(info *conf.Redis) (err error)

type RPCServer

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

func (*RPCServer) Done

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

func (*RPCServer) Finish

func (this *RPCServer) Finish()

func (*RPCServer) GetExecuting

func (s *RPCServer) GetExecuting() int64

* 获取当前正在执行的goroutine 数量

func (*RPCServer) GetLocalServer added in v1.6.7

func (s *RPCServer) GetLocalServer() mqrpc.LocalServer

func (*RPCServer) NewRabbitmqRPCServer added in v1.6.7

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

* 创建一个支持远程RPC的服务

func (*RPCServer) NewRedisRPCServer added in v1.6.7

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

* 创建一个支持远程Redis RPC的服务

func (*RPCServer) Register

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

you must call the function before calling Open and Go

func (*RPCServer) RegisterGO

func (s *RPCServer) RegisterGO(id string, f interface{})

you must call the function before calling Open and Go

func (*RPCServer) SetGoroutineControl

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

func (*RPCServer) SetListener

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

func (*RPCServer) Wait

func (this *RPCServer) Wait() error

type RabbitAgent added in v1.6.7

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

func NewRabbitAgent added in v1.6.7

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

func (*RabbitAgent) CallbackQueue added in v1.6.7

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

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

func (*RabbitAgent) ClientPublish added in v1.6.7

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

* rpc client写数据

func (*RabbitAgent) Closed added in v1.6.7

func (this *RabbitAgent) Closed() bool

func (*RabbitAgent) ExchangeDeclare added in v1.6.7

func (this *RabbitAgent) ExchangeDeclare() error

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

func (*RabbitAgent) Queue added in v1.6.7

func (this *RabbitAgent) Queue() error

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

func (*RabbitAgent) RChannel added in v1.6.7

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

* 获取读通道

func (*RabbitAgent) RConnect added in v1.6.7

func (this *RabbitAgent) RConnect() error

* 创建一个读连接

func (*RabbitAgent) ReadMsg added in v1.6.7

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

func (*RabbitAgent) ServerPublish added in v1.6.7

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

* rpc server写数据

func (*RabbitAgent) Shutdown added in v1.6.7

func (this *RabbitAgent) Shutdown() error

* 停止服务

func (*RabbitAgent) WChannel added in v1.6.7

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

* 获取写通道

func (*RabbitAgent) WConnect added in v1.6.7

func (this *RabbitAgent) WConnect() error

* 创建一个写连接

type RabbitMQInfo added in v1.6.7

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

type RedisClient added in v1.6.7

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

func NewRedisClient added in v1.6.7

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

func (*RedisClient) Call added in v1.6.7

func (c *RedisClient) Call(callInfo mqrpc.CallInfo, callback chan rpcpb.ResultInfo) error

* 消息请求

func (*RedisClient) CallNR added in v1.6.7

func (c *RedisClient) CallNR(callInfo mqrpc.CallInfo) error

* 消息请求 不需要回复

func (*RedisClient) Done added in v1.6.7

func (c *RedisClient) Done() (err error)

func (*RedisClient) Finish added in v1.6.7

func (this *RedisClient) Finish()

func (*RedisClient) Marshal added in v1.6.7

func (c *RedisClient) Marshal(rpcInfo *rpcpb.RPCInfo) ([]byte, error)

goroutine safe

func (*RedisClient) Unmarshal added in v1.6.7

func (c *RedisClient) Unmarshal(data []byte) (*rpcpb.RPCInfo, error)

func (*RedisClient) UnmarshalResult added in v1.6.7

func (c *RedisClient) UnmarshalResult(data []byte) (*rpcpb.ResultInfo, error)

func (*RedisClient) Wait added in v1.6.7

func (this *RedisClient) Wait() error

type RedisServer added in v1.6.7

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

func NewRedisServer added in v1.6.7

func NewRedisServer(info *conf.Redis, call_chan chan mqrpc.CallInfo) (*RedisServer, error)

func (*RedisServer) Callback added in v1.6.7

func (s *RedisServer) Callback(callinfo mqrpc.CallInfo) error

func (*RedisServer) MarshalResult added in v1.6.7

func (s *RedisServer) MarshalResult(resultInfo rpcpb.ResultInfo) ([]byte, error)

goroutine safe

func (*RedisServer) Shutdown added in v1.6.7

func (s *RedisServer) Shutdown() error

* 注销消息队列

func (*RedisServer) StopConsume added in v1.6.7

func (s *RedisServer) StopConsume() error

* 停止接收请求

func (*RedisServer) Unmarshal added in v1.6.7

func (s *RedisServer) Unmarshal(data []byte) (*rpcpb.RPCInfo, error)

Jump to

Keyboard shortcuts

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