agent

package module
v0.0.0-...-899fff0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

README

rpcx-agent

项目已经移至 rpcx-ecosystem/rpcx-agent

因为 rpcx 主要目的是为 Go 生态圈提供一个服务发现和服务治理的RPC框架,所以它并不直接支持其它编程语言的调用。但是实际情况是国内很多公司主要是用Java、PHP、C++、Python等编程语言作为主力语言,如何让使用这些语言的开发者调用rpcx的服务,是一个让人头疼的问题。

国内互联网企业中使用比较多的是Dubbo和Motan,它们的用户主要使用Java和PHP开发。如果你想提供一个Go语言编写的服务,不太可能要求用户换成Go语言来调用。一个解决方案是使用跨语言的RPC框架,比如gRPC,但是它缺乏服务治理的能力,服务发现和负载均衡也需要自己实现。

为了让rpcx更广泛的应用在企业的产品中,我尝试采用一种曲折而略有hack的方式来提供对rpcx的跨语言调用,这也是本项目创建的初衷。

最基本的想法提供一个Agent, 客户通过gRPC和Agent通信,Agent将请求翻译成rpcx的格式,可以利用rpcx的服务治理的能力,在集群中选择服务进行调用,它会把服务结果返回给客户。

因为客户通过gRPC和Agent进行通信,所以可以利用gRPC的跨语言的能力。只要gRPC支持的语言,都可以和rpcx进行通信。

建议将Agent部署在客户机上,这样客户和Agent进行本地通信,性能损耗可以减少懂啊最少。

目前仅支持protobuf编码的格式。

客户需要知道服务的proto的定义,它会使用这个proto准备输入参数,也会根据这个proto解出返回结果。

你可以参考 agent_test.go 看看客户是如何进行调用的。

目前这个项目还是试验性的,只是进行概念性的验证,暂时不要应用在项目中。

欢迎提出您的宝贵的意见和建议,也非常欢迎讨论rpcx的跨平台的解决方案。

Documentation

Overview

Package agent is a generated protocol buffer package.

It is generated from these files:

protobuf_test.proto

It has these top-level messages:

ProtoArgs
ProtoReply

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthProtobufTest = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProtobufTest   = fmt.Errorf("proto: integer overflow")
)

Functions

func StartAgent

func StartAgent(addr string, registry string, opts []string)

func Stop

func Stop()

Types

type ProtoArgs

type ProtoArgs struct {
	A string `protobuf:"bytes,1,opt,name=A,proto3" json:"A,omitempty"`
	B int32  `protobuf:"varint,2,opt,name=B,proto3" json:"B,omitempty"`
}

func (*ProtoArgs) Descriptor

func (*ProtoArgs) Descriptor() ([]byte, []int)

func (*ProtoArgs) GetA

func (m *ProtoArgs) GetA() string

func (*ProtoArgs) GetB

func (m *ProtoArgs) GetB() int32

func (*ProtoArgs) Marshal

func (m *ProtoArgs) Marshal() (dAtA []byte, err error)

func (*ProtoArgs) MarshalTo

func (m *ProtoArgs) MarshalTo(dAtA []byte) (int, error)

func (*ProtoArgs) ProtoMessage

func (*ProtoArgs) ProtoMessage()

func (*ProtoArgs) Reset

func (m *ProtoArgs) Reset()

func (*ProtoArgs) Size

func (m *ProtoArgs) Size() (n int)

func (*ProtoArgs) String

func (m *ProtoArgs) String() string

func (*ProtoArgs) Unmarshal

func (m *ProtoArgs) Unmarshal(dAtA []byte) error

type ProtoReply

type ProtoReply struct {
	C string `protobuf:"bytes,1,opt,name=C,proto3" json:"C,omitempty"`
	D int32  `protobuf:"varint,2,opt,name=D,proto3" json:"D,omitempty"`
}

func (*ProtoReply) Descriptor

func (*ProtoReply) Descriptor() ([]byte, []int)

func (*ProtoReply) GetC

func (m *ProtoReply) GetC() string

func (*ProtoReply) GetD

func (m *ProtoReply) GetD() int32

func (*ProtoReply) Marshal

func (m *ProtoReply) Marshal() (dAtA []byte, err error)

func (*ProtoReply) MarshalTo

func (m *ProtoReply) MarshalTo(dAtA []byte) (int, error)

func (*ProtoReply) ProtoMessage

func (*ProtoReply) ProtoMessage()

func (*ProtoReply) Reset

func (m *ProtoReply) Reset()

func (*ProtoReply) Size

func (m *ProtoReply) Size() (n int)

func (*ProtoReply) String

func (m *ProtoReply) String() string

func (*ProtoReply) Unmarshal

func (m *ProtoReply) Unmarshal(dAtA []byte) error

Directories

Path Synopsis
wirepb
Package wirepb is a generated protocol buffer package.
Package wirepb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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