v1

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_example_greeter_v1_hello_proto protoreflect.FileDescriptor
View Source
var Hello_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "greeter.service.v1.Hello",
	HandlerType: (*HelloServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Add",
			Handler:    _Hello_Add_Handler,
		},
		{
			MethodName: "Get",
			Handler:    _Hello_Get_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "example/greeter/v1/hello.proto",
}

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

Functions

func RegisterHelloHTTPHandler

func RegisterHelloHTTPHandler(g *gin.RouterGroup, srv HelloHTTPHandler)

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

func RegisterHelloServer

func RegisterHelloServer(s grpc.ServiceRegistrar, srv HelloServer)

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 added in v0.0.2

func (m *AddRequest) Validate() error

Validate checks the field values on AddRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*AddRequest) ValidateAll added in v0.0.2

func (m *AddRequest) ValidateAll() error

ValidateAll checks the field values on AddRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in AddRequestMultiError, or nil if none found.

type AddRequestMultiError added in v0.0.2

type AddRequestMultiError []error

AddRequestMultiError is an error wrapping multiple validation errors returned by AddRequest.ValidateAll() if the designated constraints aren't met.

func (AddRequestMultiError) AllErrors added in v0.0.2

func (m AddRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (AddRequestMultiError) Error added in v0.0.2

func (m AddRequestMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type AddRequestValidationError added in v0.0.2

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

AddRequestValidationError is the validation error returned by AddRequest.Validate if the designated constraints aren't met.

func (AddRequestValidationError) Cause added in v0.0.2

func (e AddRequestValidationError) Cause() error

Cause function returns cause value.

func (AddRequestValidationError) Error added in v0.0.2

Error satisfies the builtin error interface

func (AddRequestValidationError) ErrorName added in v0.0.2

func (e AddRequestValidationError) ErrorName() string

ErrorName returns error name.

func (AddRequestValidationError) Field added in v0.0.2

Field function returns field value.

func (AddRequestValidationError) Key added in v0.0.2

Key function returns key value.

func (AddRequestValidationError) Reason added in v0.0.2

func (e AddRequestValidationError) Reason() string

Reason function returns reason value.

type AddResponse

type AddResponse 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 (*AddResponse) Descriptor deprecated

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

Deprecated: Use AddResponse.ProtoReflect.Descriptor instead.

func (*AddResponse) GetId

func (x *AddResponse) GetId() uint32

func (*AddResponse) GetName

func (x *AddResponse) GetName() string

func (*AddResponse) ProtoMessage

func (*AddResponse) ProtoMessage()

func (*AddResponse) ProtoReflect

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

func (*AddResponse) Reset

func (x *AddResponse) Reset()

func (*AddResponse) String

func (x *AddResponse) String() string

func (*AddResponse) Validate added in v0.0.2

func (m *AddResponse) Validate() error

Validate checks the field values on AddResponse with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*AddResponse) ValidateAll added in v0.0.2

func (m *AddResponse) ValidateAll() error

ValidateAll checks the field values on AddResponse with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in AddResponseMultiError, or nil if none found.

type AddResponseMultiError added in v0.0.2

type AddResponseMultiError []error

AddResponseMultiError is an error wrapping multiple validation errors returned by AddResponse.ValidateAll() if the designated constraints aren't met.

func (AddResponseMultiError) AllErrors added in v0.0.2

func (m AddResponseMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (AddResponseMultiError) Error added in v0.0.2

func (m AddResponseMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type AddResponseValidationError added in v0.0.2

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

AddResponseValidationError is the validation error returned by AddResponse.Validate if the designated constraints aren't met.

func (AddResponseValidationError) Cause added in v0.0.2

Cause function returns cause value.

func (AddResponseValidationError) Error added in v0.0.2

Error satisfies the builtin error interface

func (AddResponseValidationError) ErrorName added in v0.0.2

func (e AddResponseValidationError) ErrorName() string

ErrorName returns error name.

func (AddResponseValidationError) Field added in v0.0.2

Field function returns field value.

func (AddResponseValidationError) Key added in v0.0.2

Key function returns key value.

func (AddResponseValidationError) Reason added in v0.0.2

Reason function returns reason value.

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 added in v0.0.2

func (m *GetRequest) Validate() error

Validate checks the field values on GetRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*GetRequest) ValidateAll added in v0.0.2

func (m *GetRequest) ValidateAll() error

ValidateAll checks the field values on GetRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in GetRequestMultiError, or nil if none found.

type GetRequestMultiError added in v0.0.2

type GetRequestMultiError []error

GetRequestMultiError is an error wrapping multiple validation errors returned by GetRequest.ValidateAll() if the designated constraints aren't met.

func (GetRequestMultiError) AllErrors added in v0.0.2

func (m GetRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (GetRequestMultiError) Error added in v0.0.2

func (m GetRequestMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type GetRequestValidationError added in v0.0.2

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

GetRequestValidationError is the validation error returned by GetRequest.Validate if the designated constraints aren't met.

func (GetRequestValidationError) Cause added in v0.0.2

func (e GetRequestValidationError) Cause() error

Cause function returns cause value.

func (GetRequestValidationError) Error added in v0.0.2

Error satisfies the builtin error interface

func (GetRequestValidationError) ErrorName added in v0.0.2

func (e GetRequestValidationError) ErrorName() string

ErrorName returns error name.

func (GetRequestValidationError) Field added in v0.0.2

Field function returns field value.

func (GetRequestValidationError) Key added in v0.0.2

Key function returns key value.

func (GetRequestValidationError) Reason added in v0.0.2

func (e GetRequestValidationError) Reason() string

Reason function returns reason value.

type GetResponse

type GetResponse 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"`
	Score float32           `protobuf:"fixed32,3,opt,name=score,proto3" json:"score,omitempty"`
	Bs    []byte            `protobuf:"bytes,4,opt,name=bs,proto3" json:"bs,omitempty"`
	M     map[string]string `` /* 143-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*GetResponse) Descriptor deprecated

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

Deprecated: Use GetResponse.ProtoReflect.Descriptor instead.

func (*GetResponse) GetBs

func (x *GetResponse) GetBs() []byte

func (*GetResponse) GetId

func (x *GetResponse) GetId() uint32

func (*GetResponse) GetM

func (x *GetResponse) GetM() map[string]string

func (*GetResponse) GetName

func (x *GetResponse) GetName() string

func (*GetResponse) GetScore

func (x *GetResponse) GetScore() float32

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) ProtoReflect

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

func (*GetResponse) Reset

func (x *GetResponse) Reset()

func (*GetResponse) String

func (x *GetResponse) String() string

func (*GetResponse) Validate added in v0.0.2

func (m *GetResponse) Validate() error

Validate checks the field values on GetResponse with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*GetResponse) ValidateAll added in v0.0.2

func (m *GetResponse) ValidateAll() error

ValidateAll checks the field values on GetResponse with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in GetResponseMultiError, or nil if none found.

type GetResponseMultiError added in v0.0.2

type GetResponseMultiError []error

GetResponseMultiError is an error wrapping multiple validation errors returned by GetResponse.ValidateAll() if the designated constraints aren't met.

func (GetResponseMultiError) AllErrors added in v0.0.2

func (m GetResponseMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (GetResponseMultiError) Error added in v0.0.2

func (m GetResponseMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type GetResponseValidationError added in v0.0.2

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

GetResponseValidationError is the validation error returned by GetResponse.Validate if the designated constraints aren't met.

func (GetResponseValidationError) Cause added in v0.0.2

Cause function returns cause value.

func (GetResponseValidationError) Error added in v0.0.2

Error satisfies the builtin error interface

func (GetResponseValidationError) ErrorName added in v0.0.2

func (e GetResponseValidationError) ErrorName() string

ErrorName returns error name.

func (GetResponseValidationError) Field added in v0.0.2

Field function returns field value.

func (GetResponseValidationError) Key added in v0.0.2

Key function returns key value.

func (GetResponseValidationError) Reason added in v0.0.2

Reason function returns reason value.

type HelloClient

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

HelloClient is the client API for Hello 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 NewHelloClient

func NewHelloClient(cc grpc.ClientConnInterface) HelloClient

type HelloHTTPClient added in v0.0.2

type HelloHTTPClient interface {
	Add(ctx context.Context, req *AddRequest, opts ...phttp.CallOption) (*AddResponse, error)
	Get(ctx context.Context, req *GetRequest, opts ...phttp.CallOption) (*GetResponse, error)
}

HelloHTTPClient defines call HelloServer client

func NewHelloHTTPClient added in v0.0.2

func NewHelloHTTPClient(cli *http.Client, opts ...phttp.ClientOption) (HelloHTTPClient, error)

type HelloHTTPClientImpl added in v0.0.2

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

HelloHTTPClientImpl implement HelloHTTPClient

func (*HelloHTTPClientImpl) Add added in v0.0.2

func (c *HelloHTTPClientImpl) Add(ctx context.Context, req *AddRequest, opts ...phttp.CallOption) (rsp *AddResponse, err error)

Add is call [POST] /api/hello/service/v1/add api.

func (*HelloHTTPClientImpl) Get added in v0.0.2

func (c *HelloHTTPClientImpl) Get(ctx context.Context, req *GetRequest, opts ...phttp.CallOption) (rsp *GetResponse, err error)

Get is call [GET] /api/hello/service/v1/get api.

type HelloHTTPHandler

type HelloHTTPHandler interface {
	Add(context.Context, *AddRequest) (*AddResponse, error)
	Get(context.Context, *GetRequest) (*GetResponse, error)
}

这里定义 handler interface

type HelloServer

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

HelloServer is the server API for Hello service. All implementations must embed UnimplementedHelloServer for forward compatibility

type UnimplementedHelloServer

type UnimplementedHelloServer struct {
}

UnimplementedHelloServer must be embedded to have forward compatible implementations.

func (UnimplementedHelloServer) Add

func (UnimplementedHelloServer) Get

type UnsafeHelloServer

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

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

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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