rpc

package
v1.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SERVICE_name = map[int32]string{
		0:  "NONE",
		1:  "CLIENT",
		2:  "GATE",
		3:  "GM",
		4:  "GAME",
		5:  "ZONE",
		6:  "DB",
		7:  "GATESERVER",
		8:  "ACCOUNTSERVER",
		9:  "WORLDSERVER",
		10: "ZONESERVER",
		11: "WORLDDBSERVER",
		12: "ServiceWarKings",
		13: "ServiceFruitPark",
	}
	SERVICE_value = map[string]int32{
		"NONE":             0,
		"CLIENT":           1,
		"GATE":             2,
		"GM":               3,
		"GAME":             4,
		"ZONE":             5,
		"DB":               6,
		"GATESERVER":       7,
		"ACCOUNTSERVER":    8,
		"WORLDSERVER":      9,
		"ZONESERVER":       10,
		"WORLDDBSERVER":    11,
		"ServiceWarKings":  12,
		"ServiceFruitPark": 13,
	}
)

Enum value maps for SERVICE.

View Source
var (
	SEND_name = map[int32]string{
		0: "POINT",
		1: "BALANCE",
		2: "BOARD_CAST",
	}
	SEND_value = map[string]int32{
		"POINT":      0,
		"BALANCE":    1,
		"BOARD_CAST": 2,
	}
)

Enum value maps for SEND.

View Source
var (
	STUB_name = map[int32]string{
		0: "Master",
		1: "PlayerMgr",
		2: "AccountMgr",
		3: "ChatMgr",
		4: "END",
	}
	STUB_value = map[string]int32{
		"Master":     0,
		"PlayerMgr":  1,
		"AccountMgr": 2,
		"ChatMgr":    3,
		"END":        4,
	}
)

Enum value maps for STUB.

View Source
var (
	MAIL_name = map[int32]string{
		0: "Player",
	}
	MAIL_value = map[string]int32{
		"Player": 0,
	}
)

Enum value maps for MAIL.

View Source
var TestService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "rpc.TestService",
	HandlerType: (*TestServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "TestSon",
			Handler:    _TestService_TestSon_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "rpc3.proto",
}

TestService_ServiceDesc is the grpc.ServiceDesc for TestService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func Call

func Call(parmas ...interface{})

params[0]:rpc.RpcHead params[1]:error

func MarshalJson added in v1.7.5

func MarshalJson(head api.JsonHead, funcName string, params ...interface{}) (packet api.Packet)

func RegisterTestServiceServer

func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer)

func Route

func Route(head *RpcHead, funcName string) string

func Unmarshal

func Unmarshal(buff []byte) (*RpcPacket, RpcHead)

func Unmarshal2

func Unmarshal2(buff []byte) (*RpcPacket, RpcHead)

func UnmarshalBody

func UnmarshalBody(rpcPacket *RpcPacket, pFuncType reflect.Type) []interface{}

rpc Unmarshal pFuncType for (this *X)func(conttext, params)

func UnmarshalBody2

func UnmarshalBody2(rpcPacket *RpcPacket, pFuncType reflect.Type) []interface{}

func UnmarshalBodyCall

func UnmarshalBodyCall(rpcPacket *RpcPacket, pFuncType reflect.Type) (error, []interface{})

func UnmarshalBodyJson added in v1.7.3

func UnmarshalBodyJson(jsonPacket api.JsonPacket, pFuncType reflect.Type) []interface{}

func UnmarshalHead

func UnmarshalHead(buff []byte) (*RpcPacket, RpcHead)

rpc UnmarshalHead

Types

type ClusterInfo

type ClusterInfo struct {
	Type     SERVICE `protobuf:"varint,1,opt,name=Type,proto3,enum=rpc.SERVICE" json:"Type,omitempty"`
	Ip       string  `protobuf:"bytes,2,opt,name=Ip,proto3" json:"Ip,omitempty"`
	Port     int32   `protobuf:"varint,3,opt,name=Port,proto3" json:"Port,omitempty"`
	Weight   int32   `protobuf:"varint,4,opt,name=Weight,proto3" json:"Weight,omitempty"`
	SocketId uint32  `protobuf:"varint,5,opt,name=SocketId,proto3" json:"SocketId,omitempty"`
	Url      string  `protobuf:"bytes,6,opt,name=Url,proto3" json:"Url,omitempty"`
	// contains filtered or unexported fields
}

集群信息

func (*ClusterInfo) Descriptor deprecated

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

Deprecated: Use ClusterInfo.ProtoReflect.Descriptor instead.

func (*ClusterInfo) GetIp

func (x *ClusterInfo) GetIp() string

func (*ClusterInfo) GetPort

func (x *ClusterInfo) GetPort() int32

func (*ClusterInfo) GetSocketId

func (x *ClusterInfo) GetSocketId() uint32

func (*ClusterInfo) GetType

func (x *ClusterInfo) GetType() SERVICE

func (*ClusterInfo) GetUrl

func (x *ClusterInfo) GetUrl() string

func (*ClusterInfo) GetWeight

func (x *ClusterInfo) GetWeight() int32

func (*ClusterInfo) Id added in v1.9.6

func (c *ClusterInfo) Id() uint32

func (*ClusterInfo) IpString added in v1.9.6

func (c *ClusterInfo) IpString() string

func (*ClusterInfo) ProtoMessage

func (*ClusterInfo) ProtoMessage()

func (*ClusterInfo) ProtoReflect

func (x *ClusterInfo) ProtoReflect() protoreflect.Message

func (*ClusterInfo) Reset

func (x *ClusterInfo) Reset()

func (*ClusterInfo) ServiceName added in v1.9.6

func (c *ClusterInfo) ServiceName() string

func (*ClusterInfo) ServiceType added in v1.9.6

func (c *ClusterInfo) ServiceType() SERVICE

func (*ClusterInfo) String

func (x *ClusterInfo) String() string

type F

type F struct {
	RpcPacket *RpcPacket `protobuf:"bytes,1,opt,name=RpcPacket,proto3" json:"RpcPacket,omitempty"`
	Id        int32      `protobuf:"varint,2,opt,name=Id,proto3" json:"Id,omitempty"`
	// contains filtered or unexported fields
}

func (*F) Descriptor deprecated

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

Deprecated: Use F.ProtoReflect.Descriptor instead.

func (*F) GetId

func (x *F) GetId() int32

func (*F) GetRpcPacket

func (x *F) GetRpcPacket() *RpcPacket

func (*F) ProtoMessage

func (*F) ProtoMessage()

func (*F) ProtoReflect

func (x *F) ProtoReflect() protoreflect.Message

func (*F) Reset

func (x *F) Reset()

func (*F) String

func (x *F) String() string

type ICluster

type ICluster interface {
	SendMsg(head RpcHead, funcName string, params ...interface{})
	Call(parmas ...interface{})
	Id() uint32
}
var MGR ICluster

type IClusterInfo added in v1.9.6

type IClusterInfo interface {
	Id() uint32
	ServiceName() string
	ServiceType() SERVICE
	IpString() string
}

type MAIL

type MAIL int32

邮件类型

const (
	MAIL_Player MAIL = 0 //player
)

func (MAIL) Descriptor

func (MAIL) Descriptor() protoreflect.EnumDescriptor

func (MAIL) Enum

func (x MAIL) Enum() *MAIL

func (MAIL) EnumDescriptor deprecated

func (MAIL) EnumDescriptor() ([]byte, []int)

Deprecated: Use MAIL.Descriptor instead.

func (MAIL) Number

func (x MAIL) Number() protoreflect.EnumNumber

func (MAIL) String

func (x MAIL) String() string

func (MAIL) Type

func (MAIL) Type() protoreflect.EnumType

type MailBox

type MailBox struct {
	Id        int64  `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
	LeaseId   int64  `protobuf:"varint,2,opt,name=LeaseId,proto3" json:"LeaseId,omitempty"`
	MailType  MAIL   `protobuf:"varint,3,opt,name=MailType,proto3,enum=rpc.MAIL" json:"MailType,omitempty"`
	ClusterId uint32 `protobuf:"varint,5,opt,name=ClusterId,proto3" json:"ClusterId,omitempty"` //集群id
	// contains filtered or unexported fields
}

邮箱

func (*MailBox) Descriptor deprecated

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

Deprecated: Use MailBox.ProtoReflect.Descriptor instead.

func (*MailBox) GetClusterId

func (x *MailBox) GetClusterId() uint32

func (*MailBox) GetId

func (x *MailBox) GetId() int64

func (*MailBox) GetLeaseId

func (x *MailBox) GetLeaseId() int64

func (*MailBox) GetMailType

func (x *MailBox) GetMailType() MAIL

func (*MailBox) ProtoMessage

func (*MailBox) ProtoMessage()

func (*MailBox) ProtoReflect

func (x *MailBox) ProtoReflect() protoreflect.Message

func (*MailBox) Reset

func (x *MailBox) Reset()

func (*MailBox) String

func (x *MailBox) String() string

type Packet

type Packet struct {
	Id        uint32     `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`              //socketid
	Reply     string     `protobuf:"bytes,2,opt,name=Reply,proto3" json:"Reply,omitempty"`         //call sessionid
	Buff      []byte     `protobuf:"bytes,3,opt,name=Buff,proto3" json:"Buff,omitempty"`           //buff
	RpcPacket *RpcPacket `protobuf:"bytes,4,opt,name=RpcPacket,proto3" json:"RpcPacket,omitempty"` //rpc packet
	// contains filtered or unexported fields
}

原始包

func Marshal

func Marshal(head *RpcHead, funcName *string, params ...interface{}) Packet

rpc Marshal

func (*Packet) Descriptor deprecated

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

Deprecated: Use Packet.ProtoReflect.Descriptor instead.

func (*Packet) GetBuff

func (x *Packet) GetBuff() []byte

func (*Packet) GetId

func (x *Packet) GetId() uint32

func (*Packet) GetReply

func (x *Packet) GetReply() string

func (*Packet) GetRpcPacket

func (x *Packet) GetRpcPacket() *RpcPacket

func (*Packet) ProtoMessage

func (*Packet) ProtoMessage()

func (*Packet) ProtoReflect

func (x *Packet) ProtoReflect() protoreflect.Message

func (*Packet) Reset

func (x *Packet) Reset()

func (*Packet) String

func (x *Packet) String() string

type RpcHead

type RpcHead struct {
	Id             int64   `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` //token
	SocketId       uint32  `protobuf:"varint,2,opt,name=SocketId,proto3" json:"SocketId,omitempty"`
	SrcClusterId   uint32  `protobuf:"varint,3,opt,name=SrcClusterId,proto3" json:"SrcClusterId,omitempty"`                      //源集群id
	ClusterId      uint32  `protobuf:"varint,4,opt,name=ClusterId,proto3" json:"ClusterId,omitempty"`                            //目标集群id
	DestServerType SERVICE `protobuf:"varint,5,opt,name=DestServerType,proto3,enum=rpc.SERVICE" json:"DestServerType,omitempty"` //目标集群
	SendType       SEND    `protobuf:"varint,6,opt,name=SendType,proto3,enum=rpc.SEND" json:"SendType,omitempty"`
	ActorName      string  `protobuf:"bytes,7,opt,name=ActorName,proto3" json:"ActorName,omitempty"`
	Reply          string  `protobuf:"bytes,8,opt,name=Reply,proto3" json:"Reply,omitempty"` //call sessionid
	Code           int32   `protobuf:"varint,9,opt,name=Code,proto3" json:"Code,omitempty"`
	Msg            string  `protobuf:"bytes,10,opt,name=Msg,proto3" json:"Msg,omitempty"`
	Token          string  `protobuf:"bytes,11,opt,name=Token,proto3" json:"Token,omitempty"`
	// contains filtered or unexported fields
}

rpc 包头

func (*RpcHead) Descriptor deprecated

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

Deprecated: Use RpcHead.ProtoReflect.Descriptor instead.

func (*RpcHead) GetActorName

func (x *RpcHead) GetActorName() string

func (*RpcHead) GetClusterId

func (x *RpcHead) GetClusterId() uint32

func (*RpcHead) GetCode

func (x *RpcHead) GetCode() int32

func (*RpcHead) GetDestServerType

func (x *RpcHead) GetDestServerType() SERVICE

func (*RpcHead) GetId

func (x *RpcHead) GetId() int64

func (*RpcHead) GetMsg

func (x *RpcHead) GetMsg() string

func (*RpcHead) GetReply

func (x *RpcHead) GetReply() string

func (*RpcHead) GetSendType

func (x *RpcHead) GetSendType() SEND

func (*RpcHead) GetSocketId

func (x *RpcHead) GetSocketId() uint32

func (*RpcHead) GetSrcClusterId

func (x *RpcHead) GetSrcClusterId() uint32

func (*RpcHead) GetToken

func (x *RpcHead) GetToken() string

func (*RpcHead) ProtoMessage

func (*RpcHead) ProtoMessage()

func (*RpcHead) ProtoReflect

func (x *RpcHead) ProtoReflect() protoreflect.Message

func (*RpcHead) Reset

func (x *RpcHead) Reset()

func (*RpcHead) String

func (x *RpcHead) String() string

type RpcPacket

type RpcPacket struct {
	FuncName string   `protobuf:"bytes,1,opt,name=FuncName,proto3" json:"FuncName,omitempty"`
	ArgLen   int32    `protobuf:"varint,2,opt,name=ArgLen,proto3" json:"ArgLen,omitempty"`
	RpcHead  *RpcHead `protobuf:"bytes,3,opt,name=RpcHead,proto3" json:"RpcHead,omitempty"`
	RpcBody  []byte   `protobuf:"bytes,4,opt,name=RpcBody,proto3" json:"RpcBody,omitempty"`
	// contains filtered or unexported fields
}

rpc 包

func MarshalPacket

func MarshalPacket(head RpcHead, funcName string, packet proto.Message) ([]byte, RpcPacket)

rpc MarshalPacket

func (*RpcPacket) Descriptor deprecated

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

Deprecated: Use RpcPacket.ProtoReflect.Descriptor instead.

func (*RpcPacket) GetArgLen

func (x *RpcPacket) GetArgLen() int32

func (*RpcPacket) GetFuncName

func (x *RpcPacket) GetFuncName() string

func (*RpcPacket) GetRpcBody

func (x *RpcPacket) GetRpcBody() []byte

func (*RpcPacket) GetRpcHead

func (x *RpcPacket) GetRpcHead() *RpcHead

func (*RpcPacket) ProtoMessage

func (*RpcPacket) ProtoMessage()

func (*RpcPacket) ProtoReflect

func (x *RpcPacket) ProtoReflect() protoreflect.Message

func (*RpcPacket) Reset

func (x *RpcPacket) Reset()

func (*RpcPacket) String

func (x *RpcPacket) String() string

type SEND

type SEND int32

发送标志

const (
	SEND_POINT      SEND = 0 //指定集群id
	SEND_BALANCE    SEND = 1 //负载
	SEND_BOARD_CAST SEND = 2 //广播
)

func (SEND) Descriptor

func (SEND) Descriptor() protoreflect.EnumDescriptor

func (SEND) Enum

func (x SEND) Enum() *SEND

func (SEND) EnumDescriptor deprecated

func (SEND) EnumDescriptor() ([]byte, []int)

Deprecated: Use SEND.Descriptor instead.

func (SEND) Number

func (x SEND) Number() protoreflect.EnumNumber

func (SEND) String

func (x SEND) String() string

func (SEND) Type

func (SEND) Type() protoreflect.EnumType

type SERVICE

type SERVICE int32

服务器类型

const (
	SERVICE_NONE             SERVICE = 0
	SERVICE_CLIENT           SERVICE = 1
	SERVICE_GATE             SERVICE = 2  //网关,转发服务
	SERVICE_GM               SERVICE = 3  //gamemgr
	SERVICE_GAME             SERVICE = 4  //game
	SERVICE_ZONE             SERVICE = 5  //地图
	SERVICE_DB               SERVICE = 6  //db
	SERVICE_GATESERVER       SERVICE = 7  //网关,转发服务
	SERVICE_ACCOUNTSERVER    SERVICE = 8  //账号
	SERVICE_WORLDSERVER      SERVICE = 9  //世界
	SERVICE_ZONESERVER       SERVICE = 10 //地图
	SERVICE_WORLDDBSERVER    SERVICE = 11 //db
	SERVICE_ServiceWarKings  SERVICE = 12 //王者战记
	SERVICE_ServiceFruitPark SERVICE = 13 //db水果乐园
)

func (SERVICE) Descriptor

func (SERVICE) Descriptor() protoreflect.EnumDescriptor

func (SERVICE) Enum

func (x SERVICE) Enum() *SERVICE

func (SERVICE) EnumDescriptor deprecated

func (SERVICE) EnumDescriptor() ([]byte, []int)

Deprecated: Use SERVICE.Descriptor instead.

func (SERVICE) Number

func (x SERVICE) Number() protoreflect.EnumNumber

func (SERVICE) String

func (x SERVICE) String() string

func (SERVICE) Type

func (SERVICE) Type() protoreflect.EnumType

type STUB

type STUB int32

STUB类型

const (
	STUB_Master     STUB = 0 //master
	STUB_PlayerMgr  STUB = 1 //db
	STUB_AccountMgr STUB = 2 //登录
	STUB_ChatMgr    STUB = 3 //聊天
	STUB_END        STUB = 4
)

func (STUB) Descriptor

func (STUB) Descriptor() protoreflect.EnumDescriptor

func (STUB) Enum

func (x STUB) Enum() *STUB

func (STUB) EnumDescriptor deprecated

func (STUB) EnumDescriptor() ([]byte, []int)

Deprecated: Use STUB.Descriptor instead.

func (STUB) Number

func (x STUB) Number() protoreflect.EnumNumber

func (STUB) String

func (x STUB) String() string

func (STUB) Type

func (STUB) Type() protoreflect.EnumType

type StubMailBox

type StubMailBox struct {
	Id        int64  `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
	LeaseId   int64  `protobuf:"varint,2,opt,name=LeaseId,proto3" json:"LeaseId,omitempty"`
	StubType  STUB   `protobuf:"varint,3,opt,name=StubType,proto3,enum=rpc.STUB" json:"StubType,omitempty"`
	ClusterId uint32 `protobuf:"varint,5,opt,name=ClusterId,proto3" json:"ClusterId,omitempty"` //集群id
	// contains filtered or unexported fields
}

玩法集群信息

func (*StubMailBox) Descriptor deprecated

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

Deprecated: Use StubMailBox.ProtoReflect.Descriptor instead.

func (*StubMailBox) GetClusterId

func (x *StubMailBox) GetClusterId() uint32

func (*StubMailBox) GetId

func (x *StubMailBox) GetId() int64

func (*StubMailBox) GetLeaseId

func (x *StubMailBox) GetLeaseId() int64

func (*StubMailBox) GetStubType

func (x *StubMailBox) GetStubType() STUB

func (*StubMailBox) Key added in v1.9.6

func (s *StubMailBox) Key() string

func (*StubMailBox) ProtoMessage

func (*StubMailBox) ProtoMessage()

func (*StubMailBox) ProtoReflect

func (x *StubMailBox) ProtoReflect() protoreflect.Message

func (*StubMailBox) Reset

func (x *StubMailBox) Reset()

func (*StubMailBox) String

func (x *StubMailBox) String() string

func (*StubMailBox) StubName added in v1.9.6

func (s *StubMailBox) StubName() string

type T

type T struct {
	RpcPacket *RpcPacket `protobuf:"bytes,1,opt,name=RpcPacket,proto3" json:"RpcPacket,omitempty"`
	Id        int32      `protobuf:"varint,2,opt,name=Id,proto3" json:"Id,omitempty"`
	// contains filtered or unexported fields
}

func (*T) Descriptor deprecated

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

Deprecated: Use T.ProtoReflect.Descriptor instead.

func (*T) GetId

func (x *T) GetId() int32

func (*T) GetRpcPacket

func (x *T) GetRpcPacket() *RpcPacket

func (*T) ProtoMessage

func (*T) ProtoMessage()

func (*T) ProtoReflect

func (x *T) ProtoReflect() protoreflect.Message

func (*T) Reset

func (x *T) Reset()

func (*T) String

func (x *T) String() string

type TestServiceClient

type TestServiceClient interface {
	TestSon(ctx context.Context, in *F, opts ...grpc.CallOption) (*T, error)
}

TestServiceClient is the client API for TestService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type TestServiceServer

type TestServiceServer interface {
	TestSon(context.Context, *F) (*T, error)
	// contains filtered or unexported methods
}

TestServiceServer is the server API for TestService service. All implementations must embed UnimplementedTestServiceServer for forward compatibility

type UnimplementedTestServiceServer

type UnimplementedTestServiceServer struct {
}

UnimplementedTestServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedTestServiceServer) TestSon

type UnsafeTestServiceServer

type UnsafeTestServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeTestServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TestServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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