api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	Code_name = map[int32]string{
		0:     "OK",
		10005: "InternalError",
	}
	Code_value = map[string]int32{
		"OK":            0,
		"InternalError": 10005,
	}
)

Enum value maps for Code.

View Source
var File_proto_api_api_proto protoreflect.FileDescriptor
View Source
var SimpleAPI_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "simple.SimpleAPI",
	HandlerType: (*SimpleAPIServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateSession",
			Handler:    _SimpleAPI_CreateSession_Handler,
		},
		{
			MethodName: "GetAllSessions",
			Handler:    _SimpleAPI_GetAllSessions_Handler,
		},
		{
			MethodName: "GetSession",
			Handler:    _SimpleAPI_GetSession_Handler,
		},
		{
			MethodName: "DeleteSession",
			Handler:    _SimpleAPI_DeleteSession_Handler,
		},
		{
			MethodName: "GetProtos",
			Handler:    _SimpleAPI_GetProtos_Handler,
		},
		{
			MethodName: "GetSchema",
			Handler:    _SimpleAPI_GetSchema_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "proto/api/api.proto",
}

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

Functions

func RegisterSimpleAPIHandler

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

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

func RegisterSimpleAPIHandlerClient

func RegisterSimpleAPIHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SimpleAPIClient) error

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

func RegisterSimpleAPIHandlerFromEndpoint

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

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

func RegisterSimpleAPIHandlerServer

func RegisterSimpleAPIHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SimpleAPIServer) error

RegisterSimpleAPIHandlerServer registers the http handlers for service SimpleAPI to "mux". UnaryRPC :call SimpleAPIServer 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 RegisterSimpleAPIHandlerFromEndpoint instead.

func RegisterSimpleAPIServer

func RegisterSimpleAPIServer(s grpc.ServiceRegistrar, srv SimpleAPIServer)

Types

type Code

type Code int32
const (
	Code_OK            Code = 0 // 请求成功
	Code_InternalError Code = 10005
)

func (Code) Descriptor

func (Code) Descriptor() protoreflect.EnumDescriptor

func (Code) Enum

func (x Code) Enum() *Code

func (Code) EnumDescriptor deprecated

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

Deprecated: Use Code.Descriptor instead.

func (Code) Number

func (x Code) Number() protoreflect.EnumNumber

func (Code) String

func (x Code) String() string

func (Code) Type

func (Code) Type() protoreflect.EnumType

type CreateSessionReq

type CreateSessionReq struct {
	Proto      string                      `protobuf:"bytes,1,opt,name=Proto,proto3" json:"Proto,omitempty"`
	ConfigType simple_interface.ConfigType `protobuf:"varint,2,opt,name=ConfigType,proto3,enum=interface.ConfigType" json:"ConfigType,omitempty"`
	Opt        *simple_interface.Option    `protobuf:"bytes,3,opt,name=Opt,proto3" json:"Opt,omitempty"`
	CustomOpt  string                      `protobuf:"bytes,4,opt,name=CustomOpt,proto3" json:"CustomOpt,omitempty"`
	Name       string                      `protobuf:"bytes,5,opt,name=Name,proto3" json:"Name,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateSessionReq) Descriptor deprecated

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

Deprecated: Use CreateSessionReq.ProtoReflect.Descriptor instead.

func (*CreateSessionReq) GetConfigType

func (x *CreateSessionReq) GetConfigType() simple_interface.ConfigType

func (*CreateSessionReq) GetCustomOpt

func (x *CreateSessionReq) GetCustomOpt() string

func (*CreateSessionReq) GetName

func (x *CreateSessionReq) GetName() string

func (*CreateSessionReq) GetOpt

func (*CreateSessionReq) GetProto

func (x *CreateSessionReq) GetProto() string

func (*CreateSessionReq) ProtoMessage

func (*CreateSessionReq) ProtoMessage()

func (*CreateSessionReq) ProtoReflect

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

func (*CreateSessionReq) Reset

func (x *CreateSessionReq) Reset()

func (*CreateSessionReq) String

func (x *CreateSessionReq) String() string

type CreateSessionRsp

type CreateSessionRsp struct {
	Code       Code                        `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg        string                      `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	ID         string                      `protobuf:"bytes,3,opt,name=ID,proto3" json:"ID,omitempty"`
	Proto      string                      `protobuf:"bytes,4,opt,name=Proto,proto3" json:"Proto,omitempty"`
	ConfigType simple_interface.ConfigType `protobuf:"varint,5,opt,name=ConfigType,proto3,enum=interface.ConfigType" json:"ConfigType,omitempty"`
	Config     string                      `protobuf:"bytes,6,opt,name=Config,proto3" json:"Config,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateSessionRsp) Descriptor deprecated

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

Deprecated: Use CreateSessionRsp.ProtoReflect.Descriptor instead.

func (*CreateSessionRsp) GetCode

func (x *CreateSessionRsp) GetCode() Code

func (*CreateSessionRsp) GetConfig

func (x *CreateSessionRsp) GetConfig() string

func (*CreateSessionRsp) GetConfigType

func (x *CreateSessionRsp) GetConfigType() simple_interface.ConfigType

func (*CreateSessionRsp) GetID

func (x *CreateSessionRsp) GetID() string

func (*CreateSessionRsp) GetMsg

func (x *CreateSessionRsp) GetMsg() string

func (*CreateSessionRsp) GetProto

func (x *CreateSessionRsp) GetProto() string

func (*CreateSessionRsp) ProtoMessage

func (*CreateSessionRsp) ProtoMessage()

func (*CreateSessionRsp) ProtoReflect

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

func (*CreateSessionRsp) Reset

func (x *CreateSessionRsp) Reset()

func (*CreateSessionRsp) String

func (x *CreateSessionRsp) String() string

type DeleteSessionReq

type DeleteSessionReq struct {
	IDorName string `protobuf:"bytes,1,opt,name=IDorName,proto3" json:"IDorName,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteSessionReq) Descriptor deprecated

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

Deprecated: Use DeleteSessionReq.ProtoReflect.Descriptor instead.

func (*DeleteSessionReq) GetIDorName

func (x *DeleteSessionReq) GetIDorName() string

func (*DeleteSessionReq) ProtoMessage

func (*DeleteSessionReq) ProtoMessage()

func (*DeleteSessionReq) ProtoReflect

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

func (*DeleteSessionReq) Reset

func (x *DeleteSessionReq) Reset()

func (*DeleteSessionReq) String

func (x *DeleteSessionReq) String() string

type DeleteSessionRsp

type DeleteSessionRsp struct {
	Code Code   `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg  string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteSessionRsp) Descriptor deprecated

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

Deprecated: Use DeleteSessionRsp.ProtoReflect.Descriptor instead.

func (*DeleteSessionRsp) GetCode

func (x *DeleteSessionRsp) GetCode() Code

func (*DeleteSessionRsp) GetMsg

func (x *DeleteSessionRsp) GetMsg() string

func (*DeleteSessionRsp) ProtoMessage

func (*DeleteSessionRsp) ProtoMessage()

func (*DeleteSessionRsp) ProtoReflect

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

func (*DeleteSessionRsp) Reset

func (x *DeleteSessionRsp) Reset()

func (*DeleteSessionRsp) String

func (x *DeleteSessionRsp) String() string

type GetAllSessionsReq

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

func (*GetAllSessionsReq) Descriptor deprecated

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

Deprecated: Use GetAllSessionsReq.ProtoReflect.Descriptor instead.

func (*GetAllSessionsReq) ProtoMessage

func (*GetAllSessionsReq) ProtoMessage()

func (*GetAllSessionsReq) ProtoReflect

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

func (*GetAllSessionsReq) Reset

func (x *GetAllSessionsReq) Reset()

func (*GetAllSessionsReq) String

func (x *GetAllSessionsReq) String() string

type GetAllSessionsRsp

type GetAllSessionsRsp struct {
	Code     Code       `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg      string     `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	Sessions []*Session `protobuf:"bytes,3,rep,name=Sessions,proto3" json:"Sessions,omitempty"`
	// contains filtered or unexported fields
}

func (*GetAllSessionsRsp) Descriptor deprecated

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

Deprecated: Use GetAllSessionsRsp.ProtoReflect.Descriptor instead.

func (*GetAllSessionsRsp) GetCode

func (x *GetAllSessionsRsp) GetCode() Code

func (*GetAllSessionsRsp) GetMsg

func (x *GetAllSessionsRsp) GetMsg() string

func (*GetAllSessionsRsp) GetSessions

func (x *GetAllSessionsRsp) GetSessions() []*Session

func (*GetAllSessionsRsp) ProtoMessage

func (*GetAllSessionsRsp) ProtoMessage()

func (*GetAllSessionsRsp) ProtoReflect

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

func (*GetAllSessionsRsp) Reset

func (x *GetAllSessionsRsp) Reset()

func (*GetAllSessionsRsp) String

func (x *GetAllSessionsRsp) String() string

type GetProtosReq

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

func (*GetProtosReq) Descriptor deprecated

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

Deprecated: Use GetProtosReq.ProtoReflect.Descriptor instead.

func (*GetProtosReq) ProtoMessage

func (*GetProtosReq) ProtoMessage()

func (*GetProtosReq) ProtoReflect

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

func (*GetProtosReq) Reset

func (x *GetProtosReq) Reset()

func (*GetProtosReq) String

func (x *GetProtosReq) String() string

type GetProtosRsp

type GetProtosRsp struct {
	Code   Code     `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg    string   `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	Protos []string `protobuf:"bytes,3,rep,name=Protos,proto3" json:"Protos,omitempty"`
	// contains filtered or unexported fields
}

func (*GetProtosRsp) Descriptor deprecated

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

Deprecated: Use GetProtosRsp.ProtoReflect.Descriptor instead.

func (*GetProtosRsp) GetCode

func (x *GetProtosRsp) GetCode() Code

func (*GetProtosRsp) GetMsg

func (x *GetProtosRsp) GetMsg() string

func (*GetProtosRsp) GetProtos

func (x *GetProtosRsp) GetProtos() []string

func (*GetProtosRsp) ProtoMessage

func (*GetProtosRsp) ProtoMessage()

func (*GetProtosRsp) ProtoReflect

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

func (*GetProtosRsp) Reset

func (x *GetProtosRsp) Reset()

func (*GetProtosRsp) String

func (x *GetProtosRsp) String() string

type GetSchemaReq

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

func (*GetSchemaReq) Descriptor deprecated

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

Deprecated: Use GetSchemaReq.ProtoReflect.Descriptor instead.

func (*GetSchemaReq) ProtoMessage

func (*GetSchemaReq) ProtoMessage()

func (*GetSchemaReq) ProtoReflect

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

func (*GetSchemaReq) Reset

func (x *GetSchemaReq) Reset()

func (*GetSchemaReq) String

func (x *GetSchemaReq) String() string

type GetSchemaRsp

type GetSchemaRsp struct {
	Code    Code               `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg     string             `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	Schemas map[string]*Schema `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*GetSchemaRsp) Descriptor deprecated

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

Deprecated: Use GetSchemaRsp.ProtoReflect.Descriptor instead.

func (*GetSchemaRsp) GetCode

func (x *GetSchemaRsp) GetCode() Code

func (*GetSchemaRsp) GetMsg

func (x *GetSchemaRsp) GetMsg() string

func (*GetSchemaRsp) GetSchemas

func (x *GetSchemaRsp) GetSchemas() map[string]*Schema

func (*GetSchemaRsp) ProtoMessage

func (*GetSchemaRsp) ProtoMessage()

func (*GetSchemaRsp) ProtoReflect

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

func (*GetSchemaRsp) Reset

func (x *GetSchemaRsp) Reset()

func (*GetSchemaRsp) String

func (x *GetSchemaRsp) String() string

type GetSessionReq

type GetSessionReq struct {
	IDorName string `protobuf:"bytes,1,opt,name=IDorName,proto3" json:"IDorName,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSessionReq) Descriptor deprecated

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

Deprecated: Use GetSessionReq.ProtoReflect.Descriptor instead.

func (*GetSessionReq) GetIDorName

func (x *GetSessionReq) GetIDorName() string

func (*GetSessionReq) ProtoMessage

func (*GetSessionReq) ProtoMessage()

func (*GetSessionReq) ProtoReflect

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

func (*GetSessionReq) Reset

func (x *GetSessionReq) Reset()

func (*GetSessionReq) String

func (x *GetSessionReq) String() string

type GetSessionRsp

type GetSessionRsp struct {
	Code    Code     `protobuf:"varint,1,opt,name=Code,proto3,enum=simple.Code" json:"Code,omitempty"`
	Msg     string   `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
	Session *Session `protobuf:"bytes,3,opt,name=Session,proto3" json:"Session,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSessionRsp) Descriptor deprecated

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

Deprecated: Use GetSessionRsp.ProtoReflect.Descriptor instead.

func (*GetSessionRsp) GetCode

func (x *GetSessionRsp) GetCode() Code

func (*GetSessionRsp) GetMsg

func (x *GetSessionRsp) GetMsg() string

func (*GetSessionRsp) GetSession

func (x *GetSessionRsp) GetSession() *Session

func (*GetSessionRsp) ProtoMessage

func (*GetSessionRsp) ProtoMessage()

func (*GetSessionRsp) ProtoReflect

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

func (*GetSessionRsp) Reset

func (x *GetSessionRsp) Reset()

func (*GetSessionRsp) String

func (x *GetSessionRsp) String() string

type Schema

type Schema struct {
	Proto  string                    `protobuf:"bytes,1,opt,name=Proto,proto3" json:"Proto,omitempty"`
	Fields []*simple_interface.Field `protobuf:"bytes,2,rep,name=Fields,proto3" json:"Fields,omitempty"`
	// contains filtered or unexported fields
}

func (*Schema) Descriptor deprecated

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

Deprecated: Use Schema.ProtoReflect.Descriptor instead.

func (*Schema) GetFields

func (x *Schema) GetFields() []*simple_interface.Field

func (*Schema) GetProto

func (x *Schema) GetProto() string

func (*Schema) ProtoMessage

func (*Schema) ProtoMessage()

func (*Schema) ProtoReflect

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

func (*Schema) Reset

func (x *Schema) Reset()

func (*Schema) String

func (x *Schema) String() string

type Session

type Session struct {
	ID         string                      `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
	Proto      string                      `protobuf:"bytes,2,opt,name=Proto,proto3" json:"Proto,omitempty"`
	ConfigType simple_interface.ConfigType `protobuf:"varint,3,opt,name=ConfigType,proto3,enum=interface.ConfigType" json:"ConfigType,omitempty"`
	Config     string                      `protobuf:"bytes,4,opt,name=Config,proto3" json:"Config,omitempty"`
	Opt        *simple_interface.Option    `protobuf:"bytes,5,opt,name=Opt,proto3" json:"Opt,omitempty"`
	Name       string                      `protobuf:"bytes,6,opt,name=Name,proto3" json:"Name,omitempty"`
	// contains filtered or unexported fields
}

func (*Session) Descriptor deprecated

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

Deprecated: Use Session.ProtoReflect.Descriptor instead.

func (*Session) GetConfig

func (x *Session) GetConfig() string

func (*Session) GetConfigType

func (x *Session) GetConfigType() simple_interface.ConfigType

func (*Session) GetID

func (x *Session) GetID() string

func (*Session) GetName

func (x *Session) GetName() string

func (*Session) GetOpt

func (x *Session) GetOpt() *simple_interface.Option

func (*Session) GetProto

func (x *Session) GetProto() string

func (*Session) ProtoMessage

func (*Session) ProtoMessage()

func (*Session) ProtoReflect

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

func (*Session) Reset

func (x *Session) Reset()

func (*Session) String

func (x *Session) String() string

type SimpleAPIClient

type SimpleAPIClient interface {
	CreateSession(ctx context.Context, in *CreateSessionReq, opts ...grpc.CallOption) (*CreateSessionRsp, error)
	GetAllSessions(ctx context.Context, in *GetAllSessionsReq, opts ...grpc.CallOption) (*GetAllSessionsRsp, error)
	GetSession(ctx context.Context, in *GetSessionReq, opts ...grpc.CallOption) (*GetSessionRsp, error)
	DeleteSession(ctx context.Context, in *DeleteSessionReq, opts ...grpc.CallOption) (*DeleteSessionRsp, error)
	GetProtos(ctx context.Context, in *GetProtosReq, opts ...grpc.CallOption) (*GetProtosRsp, error)
	GetSchema(ctx context.Context, in *GetSchemaReq, opts ...grpc.CallOption) (*GetSchemaRsp, error)
}

SimpleAPIClient is the client API for SimpleAPI 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 NewSimpleAPIClient

func NewSimpleAPIClient(cc grpc.ClientConnInterface) SimpleAPIClient

type SimpleAPIServer

type SimpleAPIServer interface {
	CreateSession(context.Context, *CreateSessionReq) (*CreateSessionRsp, error)
	GetAllSessions(context.Context, *GetAllSessionsReq) (*GetAllSessionsRsp, error)
	GetSession(context.Context, *GetSessionReq) (*GetSessionRsp, error)
	DeleteSession(context.Context, *DeleteSessionReq) (*DeleteSessionRsp, error)
	GetProtos(context.Context, *GetProtosReq) (*GetProtosRsp, error)
	GetSchema(context.Context, *GetSchemaReq) (*GetSchemaRsp, error)
	// contains filtered or unexported methods
}

SimpleAPIServer is the server API for SimpleAPI service. All implementations must embed UnimplementedSimpleAPIServer for forward compatibility

type UnimplementedSimpleAPIServer

type UnimplementedSimpleAPIServer struct {
}

UnimplementedSimpleAPIServer must be embedded to have forward compatible implementations.

func (UnimplementedSimpleAPIServer) CreateSession

func (UnimplementedSimpleAPIServer) DeleteSession

func (UnimplementedSimpleAPIServer) GetAllSessions

func (UnimplementedSimpleAPIServer) GetProtos

func (UnimplementedSimpleAPIServer) GetSchema

func (UnimplementedSimpleAPIServer) GetSession

type UnsafeSimpleAPIServer

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

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

Jump to

Keyboard shortcuts

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