example

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Example_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "example.Example",
	HandlerType: (*ExampleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Add",
			Handler:    _Example_Add_Handler,
		},
		{
			MethodName: "Get",
			Handler:    _Example_Get_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "proto/example/example.proto",
}

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

View Source
var File_proto_example_example_proto protoreflect.FileDescriptor

Functions

func RegisterExampleHTTPHandler

func RegisterExampleHTTPHandler(g *gin.RouterGroup, srv ExampleHTTPHandler)

RegisterExampleHTTPHandler define http router handle by gin. 注册路由 handler

func RegisterExampleServer

func RegisterExampleServer(s grpc.ServiceRegistrar, srv ExampleServer)

Types

type AddRequest

type AddRequest struct {
	Id   uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*AddRequest) Descriptor deprecated

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

Deprecated: Use AddRequest.ProtoReflect.Descriptor instead.

func (*AddRequest) GetId

func (x *AddRequest) GetId() uint32

func (*AddRequest) GetName

func (x *AddRequest) GetName() string

func (*AddRequest) ProtoMessage

func (*AddRequest) ProtoMessage()

func (*AddRequest) ProtoReflect

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

func (*AddRequest) Reset

func (x *AddRequest) Reset()

func (*AddRequest) String

func (x *AddRequest) String() string

func (*AddRequest) Validate

func (this *AddRequest) Validate() error

type CommonResponse

type CommonResponse struct {
	Code int64  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Desc string `protobuf:"bytes,2,opt,name=desc,proto3" json:"desc,omitempty"`
	Data *Empty `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*CommonResponse) Descriptor deprecated

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

Deprecated: Use CommonResponse.ProtoReflect.Descriptor instead.

func (*CommonResponse) GetCode

func (x *CommonResponse) GetCode() int64

func (*CommonResponse) GetData

func (x *CommonResponse) GetData() *Empty

func (*CommonResponse) GetDesc

func (x *CommonResponse) GetDesc() string

func (*CommonResponse) ProtoMessage

func (*CommonResponse) ProtoMessage()

func (*CommonResponse) ProtoReflect

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

func (*CommonResponse) Reset

func (x *CommonResponse) Reset()

func (*CommonResponse) String

func (x *CommonResponse) String() string

func (*CommonResponse) Validate

func (this *CommonResponse) Validate() error

type Empty

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

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

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

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

func (*Empty) Validate

func (this *Empty) Validate() error

type ExampleClient

type ExampleClient interface {
	Add(ctx context.Context, in *AddRequest, opts ...grpc.CallOption) (*CommonResponse, error)
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*CommonResponse, error)
}

ExampleClient is the client API for Example 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.

func NewExampleClient

func NewExampleClient(cc grpc.ClientConnInterface) ExampleClient

type ExampleHTTPHandler

type ExampleHTTPHandler interface {
	Add(context.Context, *AddRequest) (*CommonResponse, error)
	Get(context.Context, *GetRequest) (*CommonResponse, error)
}

这里定义 handler interface

type ExampleServer

type ExampleServer interface {
	Add(context.Context, *AddRequest) (*CommonResponse, error)
	Get(context.Context, *GetRequest) (*CommonResponse, error)
	// contains filtered or unexported methods
}

ExampleServer is the server API for Example service. All implementations must embed UnimplementedExampleServer for forward compatibility

type GetRequest

type GetRequest struct {
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetRequest) Descriptor deprecated

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

Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.

func (*GetRequest) GetId

func (x *GetRequest) GetId() uint32

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) ProtoReflect

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

func (*GetRequest) Reset

func (x *GetRequest) Reset()

func (*GetRequest) String

func (x *GetRequest) String() string

func (*GetRequest) Validate

func (this *GetRequest) Validate() error

type UnimplementedExampleServer

type UnimplementedExampleServer struct {
}

UnimplementedExampleServer must be embedded to have forward compatible implementations.

func (UnimplementedExampleServer) Add

func (UnimplementedExampleServer) Get

type UnsafeExampleServer

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

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

Jump to

Keyboard shortcuts

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