example

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthExample        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowExample          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupExample = fmt.Errorf("proto: unexpected end of group")
)
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)

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"`
}

func (*AddRequest) Descriptor

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

func (*AddRequest) GetId

func (m *AddRequest) GetId() uint32

func (*AddRequest) GetName

func (m *AddRequest) GetName() string

func (*AddRequest) Marshal added in v1.0.5

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

func (*AddRequest) MarshalTo added in v1.0.5

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

func (*AddRequest) MarshalToSizedBuffer added in v1.0.5

func (m *AddRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*AddRequest) ProtoMessage

func (*AddRequest) ProtoMessage()

func (*AddRequest) Reset

func (m *AddRequest) Reset()

func (*AddRequest) Size added in v1.0.5

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

func (*AddRequest) String

func (m *AddRequest) String() string

func (*AddRequest) Unmarshal added in v1.0.5

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

func (*AddRequest) Validate

func (this *AddRequest) Validate() error

func (*AddRequest) XXX_DiscardUnknown added in v1.0.5

func (m *AddRequest) XXX_DiscardUnknown()

func (*AddRequest) XXX_Marshal added in v1.0.5

func (m *AddRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AddRequest) XXX_Merge added in v1.0.5

func (m *AddRequest) XXX_Merge(src proto.Message)

func (*AddRequest) XXX_Size added in v1.0.5

func (m *AddRequest) XXX_Size() int

func (*AddRequest) XXX_Unmarshal added in v1.0.5

func (m *AddRequest) XXX_Unmarshal(b []byte) error

type Client added in v1.0.5

type Client interface {
	Call(ctx context.Context, req, rsp interface{}) error
}

Client defines call remote server client and implement selector

type CommonResponse

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

func (*CommonResponse) Descriptor

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

func (*CommonResponse) GetCode

func (m *CommonResponse) GetCode() int64

func (*CommonResponse) GetData

func (m *CommonResponse) GetData() *Empty

func (*CommonResponse) GetDesc

func (m *CommonResponse) GetDesc() string

func (*CommonResponse) Marshal added in v1.0.5

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

func (*CommonResponse) MarshalTo added in v1.0.5

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

func (*CommonResponse) MarshalToSizedBuffer added in v1.0.5

func (m *CommonResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommonResponse) ProtoMessage

func (*CommonResponse) ProtoMessage()

func (*CommonResponse) Reset

func (m *CommonResponse) Reset()

func (*CommonResponse) Size added in v1.0.5

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

func (*CommonResponse) String

func (m *CommonResponse) String() string

func (*CommonResponse) Unmarshal added in v1.0.5

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

func (*CommonResponse) Validate

func (this *CommonResponse) Validate() error

func (*CommonResponse) XXX_DiscardUnknown added in v1.0.5

func (m *CommonResponse) XXX_DiscardUnknown()

func (*CommonResponse) XXX_Marshal added in v1.0.5

func (m *CommonResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CommonResponse) XXX_Merge added in v1.0.5

func (m *CommonResponse) XXX_Merge(src proto.Message)

func (*CommonResponse) XXX_Size added in v1.0.5

func (m *CommonResponse) XXX_Size() int

func (*CommonResponse) XXX_Unmarshal added in v1.0.5

func (m *CommonResponse) XXX_Unmarshal(b []byte) error

type Empty

type Empty struct {
}

func (*Empty) Descriptor

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

func (*Empty) Marshal added in v1.0.5

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

func (*Empty) MarshalTo added in v1.0.5

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

func (*Empty) MarshalToSizedBuffer added in v1.0.5

func (m *Empty) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) Size added in v1.0.5

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

func (*Empty) String

func (m *Empty) String() string

func (*Empty) Unmarshal added in v1.0.5

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

func (*Empty) Validate

func (this *Empty) Validate() error

func (*Empty) XXX_DiscardUnknown added in v1.0.5

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal added in v1.0.5

func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Empty) XXX_Merge added in v1.0.5

func (m *Empty) XXX_Merge(src proto.Message)

func (*Empty) XXX_Size added in v1.0.5

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal added in v1.0.5

func (m *Empty) XXX_Unmarshal(b []byte) 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 ExampleHTTPClient added in v1.0.2

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

ExampleHTTPClient defines call ExampleServer client

func NewExampleHTTPClient added in v1.0.2

func NewExampleHTTPClient(cli Client) ExampleHTTPClient

type ExampleHTTPClientImpl added in v1.0.2

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

ExampleHTTPClientImpl implement ExampleHTTPClient

func (*ExampleHTTPClientImpl) Add added in v1.0.2

func (c *ExampleHTTPClientImpl) Add(ctx context.Context, req *AddRequest) (resp *CommonResponse, err error)

func (*ExampleHTTPClientImpl) Get added in v1.0.2

func (c *ExampleHTTPClientImpl) Get(ctx context.Context, req *GetRequest) (resp *CommonResponse, err error)

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"`
}

func (*GetRequest) Descriptor

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

func (*GetRequest) GetId

func (m *GetRequest) GetId() uint32

func (*GetRequest) Marshal added in v1.0.5

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

func (*GetRequest) MarshalTo added in v1.0.5

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

func (*GetRequest) MarshalToSizedBuffer added in v1.0.5

func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) Size added in v1.0.5

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

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) Unmarshal added in v1.0.5

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

func (*GetRequest) Validate

func (this *GetRequest) Validate() error

func (*GetRequest) XXX_DiscardUnknown added in v1.0.5

func (m *GetRequest) XXX_DiscardUnknown()

func (*GetRequest) XXX_Marshal added in v1.0.5

func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetRequest) XXX_Merge added in v1.0.5

func (m *GetRequest) XXX_Merge(src proto.Message)

func (*GetRequest) XXX_Size added in v1.0.5

func (m *GetRequest) XXX_Size() int

func (*GetRequest) XXX_Unmarshal added in v1.0.5

func (m *GetRequest) XXX_Unmarshal(b []byte) 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