v1

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

Functions

func RegisterUserHandler

func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUserHandlerClient

func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error

RegisterUserHandlerClient registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserClient" to call the correct interceptors.

func RegisterUserHandlerFromEndpoint

func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterUserHandlerServer

func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error

RegisterUserHandlerServer registers the http handlers for service User to "mux". UnaryRPC :call UserServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserHandlerFromEndpoint instead.

func RegisterUserServer

func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)

Types

type PingMsg added in v1.11.0

type PingMsg struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Count   int64  `protobuf:"zigzag64,2,opt,name=count,proto3" json:"count,omitempty"`
	// contains filtered or unexported fields
}

ping message

func (*PingMsg) Descriptor deprecated added in v1.11.0

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

Deprecated: Use PingMsg.ProtoReflect.Descriptor instead.

func (*PingMsg) GetCount added in v1.11.0

func (x *PingMsg) GetCount() int64

func (*PingMsg) GetMessage added in v1.11.0

func (x *PingMsg) GetMessage() string

func (*PingMsg) ProtoMessage added in v1.11.0

func (*PingMsg) ProtoMessage()

func (*PingMsg) ProtoReflect added in v1.11.0

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

func (*PingMsg) Reset added in v1.11.0

func (x *PingMsg) Reset()

func (*PingMsg) String added in v1.11.0

func (x *PingMsg) String() string

type PingReply added in v1.11.0

type PingReply struct {

	// 业务错误码
	Code int64 `protobuf:"zigzag64,1,opt,name=code,proto3" json:"code,omitempty"`
	// 业务错误信息
	Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	// 业务数据
	Data *PingMsg `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

ping reply

func (*PingReply) Descriptor deprecated added in v1.11.0

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

Deprecated: Use PingReply.ProtoReflect.Descriptor instead.

func (*PingReply) GetCode added in v1.11.0

func (x *PingReply) GetCode() int64

func (*PingReply) GetData added in v1.11.0

func (x *PingReply) GetData() *PingMsg

func (*PingReply) GetMsg added in v1.11.0

func (x *PingReply) GetMsg() string

func (*PingReply) ProtoMessage added in v1.11.0

func (*PingReply) ProtoMessage()

func (*PingReply) ProtoReflect added in v1.11.0

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

func (*PingReply) Reset added in v1.11.0

func (x *PingReply) Reset()

func (*PingReply) String added in v1.11.0

func (x *PingReply) String() string

type PingReq added in v1.11.0

type PingReq struct {

	// 业务数据
	Data *PingMsg `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

ping request

func (*PingReq) Descriptor deprecated added in v1.11.0

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

Deprecated: Use PingReq.ProtoReflect.Descriptor instead.

func (*PingReq) GetData added in v1.11.0

func (x *PingReq) GetData() *PingMsg

func (*PingReq) ProtoMessage added in v1.11.0

func (*PingReq) ProtoMessage()

func (*PingReq) ProtoReflect added in v1.11.0

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

func (*PingReq) Reset added in v1.11.0

func (x *PingReq) Reset()

func (*PingReq) String added in v1.11.0

func (x *PingReq) String() string

type UnimplementedUserServer

type UnimplementedUserServer struct {
}

UnimplementedUserServer should be embedded to have forward compatible implementations.

func (UnimplementedUserServer) CreateUser

func (UnimplementedUserServer) DeleteUser

func (UnimplementedUserServer) Ping

func (UnimplementedUserServer) ReadUser

func (UnimplementedUserServer) UpdateUser

type UnsafeUserServer added in v1.11.0

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

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

type UserClient

type UserClient interface {
	// ping by message
	Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingReply, error)
	// create user by user data
	CreateUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error)
	// read user by uid
	ReadUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error)
	// update user by user data
	UpdateUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error)
	// delete user by uid
	DeleteUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error)
}

UserClient is the client API for User 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 NewUserClient

func NewUserClient(cc grpc.ClientConnInterface) UserClient

type UserMsg added in v1.11.0

type UserMsg struct {
	Uid  int64  `protobuf:"zigzag64,1,opt,name=uid,proto3" json:"uid,omitempty"`
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Sex  int64  `protobuf:"zigzag64,3,opt,name=sex,proto3" json:"sex,omitempty"`
	// contains filtered or unexported fields
}

user message

func (*UserMsg) Descriptor deprecated added in v1.11.0

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

Deprecated: Use UserMsg.ProtoReflect.Descriptor instead.

func (*UserMsg) GetName added in v1.11.0

func (x *UserMsg) GetName() string

func (*UserMsg) GetSex added in v1.11.0

func (x *UserMsg) GetSex() int64

func (*UserMsg) GetUid added in v1.11.0

func (x *UserMsg) GetUid() int64

func (*UserMsg) ProtoMessage added in v1.11.0

func (*UserMsg) ProtoMessage()

func (*UserMsg) ProtoReflect added in v1.11.0

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

func (*UserMsg) Reset added in v1.11.0

func (x *UserMsg) Reset()

func (*UserMsg) String added in v1.11.0

func (x *UserMsg) String() string

type UserReply added in v1.11.0

type UserReply struct {

	// 业务错误码
	Code int64 `protobuf:"zigzag64,1,opt,name=code,proto3" json:"code,omitempty"`
	// 业务错误信息
	Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	// 业务数据
	Data *UserMsg `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

user reply

func (*UserReply) Descriptor deprecated added in v1.11.0

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

Deprecated: Use UserReply.ProtoReflect.Descriptor instead.

func (*UserReply) GetCode added in v1.11.0

func (x *UserReply) GetCode() int64

func (*UserReply) GetData added in v1.11.0

func (x *UserReply) GetData() *UserMsg

func (*UserReply) GetMsg added in v1.11.0

func (x *UserReply) GetMsg() string

func (*UserReply) ProtoMessage added in v1.11.0

func (*UserReply) ProtoMessage()

func (*UserReply) ProtoReflect added in v1.11.0

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

func (*UserReply) Reset added in v1.11.0

func (x *UserReply) Reset()

func (*UserReply) String added in v1.11.0

func (x *UserReply) String() string

type UserReq added in v1.11.0

type UserReq struct {

	// 业务数据
	Data *UserMsg `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

user request

func (*UserReq) Descriptor deprecated added in v1.11.0

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

Deprecated: Use UserReq.ProtoReflect.Descriptor instead.

func (*UserReq) GetData added in v1.11.0

func (x *UserReq) GetData() *UserMsg

func (*UserReq) ProtoMessage added in v1.11.0

func (*UserReq) ProtoMessage()

func (*UserReq) ProtoReflect added in v1.11.0

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

func (*UserReq) Reset added in v1.11.0

func (x *UserReq) Reset()

func (*UserReq) String added in v1.11.0

func (x *UserReq) String() string

type UserServer

type UserServer interface {
	// ping by message
	Ping(context.Context, *PingReq) (*PingReply, error)
	// create user by user data
	CreateUser(context.Context, *UserReq) (*UserReply, error)
	// read user by uid
	ReadUser(context.Context, *UserReq) (*UserReply, error)
	// update user by user data
	UpdateUser(context.Context, *UserReq) (*UserReply, error)
	// delete user by uid
	DeleteUser(context.Context, *UserReq) (*UserReply, error)
}

UserServer is the server API for User service. All implementations should embed UnimplementedUserServer for forward compatibility

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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