Documentation ¶
Overview ¶
Package API is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterAPIHandlerClient(ctx context.Context, mux *runtime.ServeMux, client APIClient) error
- func RegisterAPIHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterAPIHandlerServer(ctx context.Context, mux *runtime.ServeMux, server APIServer) error
- func RegisterAPIServer(s grpc.ServiceRegistrar, srv APIServer)
- type APIClient
- type APIServer
- type Meta
- type QueueMap
- func (*QueueMap) Descriptor() ([]byte, []int)deprecated
- func (x *QueueMap) GetQueues() map[string]*QueueProgress
- func (x *QueueMap) GetTotalItems() int32
- func (*QueueMap) ProtoMessage()
- func (x *QueueMap) ProtoReflect() protoreflect.Message
- func (x *QueueMap) Reset()
- func (x *QueueMap) String() string
- type QueueProgress
- func (*QueueProgress) Descriptor() ([]byte, []int)deprecated
- func (x *QueueProgress) GetCompletedCount() int32
- func (x *QueueProgress) GetExpiredCount() int32
- func (x *QueueProgress) GetFailedCount() int32
- func (x *QueueProgress) GetIncomingCount() int32
- func (x *QueueProgress) GetReceivedCount() int32
- func (x *QueueProgress) GetRunningCount() int32
- func (*QueueProgress) ProtoMessage()
- func (x *QueueProgress) ProtoReflect() protoreflect.Message
- func (x *QueueProgress) Reset()
- func (x *QueueProgress) String() string
- type RequestMessage
- func (*RequestMessage) Descriptor() ([]byte, []int)deprecated
- func (x *RequestMessage) GetExpirationSec() int32
- func (x *RequestMessage) GetLimit() int32
- func (x *RequestMessage) GetPhase() string
- func (x *RequestMessage) GetQueueID() string
- func (*RequestMessage) ProtoMessage()
- func (x *RequestMessage) ProtoReflect() protoreflect.Message
- func (x *RequestMessage) Reset()
- func (x *RequestMessage) String() string
- type Status
- type StatusMessage
- func (*StatusMessage) Descriptor() ([]byte, []int)deprecated
- func (x *StatusMessage) GetDetail() string
- func (x *StatusMessage) GetStatus() Status
- func (*StatusMessage) ProtoMessage()
- func (x *StatusMessage) ProtoReflect() protoreflect.Message
- func (x *StatusMessage) Reset()
- func (x *StatusMessage) String() string
- type Task
- func (*Task) Descriptor() ([]byte, []int)deprecated
- func (x *Task) GetBody() string
- func (x *Task) GetEnvs() []string
- func (x *Task) GetExpirationSec() int32
- func (x *Task) GetQueueID() string
- func (x *Task) GetTaskID() string
- func (*Task) ProtoMessage()
- func (x *Task) ProtoReflect() protoreflect.Message
- func (x *Task) Reset()
- func (x *Task) String() string
- type TaskList
- type UnimplementedAPIServer
- func (UnimplementedAPIServer) Complete(context.Context, *Task) (*StatusMessage, error)
- func (UnimplementedAPIServer) Fail(context.Context, *Task) (*StatusMessage, error)
- func (UnimplementedAPIServer) Healthz(context.Context, *emptypb.Empty) (*StatusMessage, error)
- func (UnimplementedAPIServer) HeartBeat(context.Context, *Task) (*StatusMessage, error)
- func (UnimplementedAPIServer) ListQueues(context.Context, *emptypb.Empty) (*QueueMap, error)
- func (UnimplementedAPIServer) LoadTask(context.Context, *RequestMessage) (*Task, error)
- func (UnimplementedAPIServer) Peek(context.Context, *RequestMessage) (*TaskList, error)
- func (UnimplementedAPIServer) Progress(context.Context, *RequestMessage) (*QueueProgress, error)
- func (UnimplementedAPIServer) PushTask(context.Context, *Task) (*StatusMessage, error)
- type UnsafeAPIServer
Constants ¶
const ( API_Healthz_FullMethodName = "/API.API/Healthz" API_PushTask_FullMethodName = "/API.API/PushTask" API_LoadTask_FullMethodName = "/API.API/LoadTask" API_HeartBeat_FullMethodName = "/API.API/HeartBeat" API_Complete_FullMethodName = "/API.API/Complete" API_Fail_FullMethodName = "/API.API/Fail" API_Progress_FullMethodName = "/API.API/Progress" API_Peek_FullMethodName = "/API.API/Peek" API_ListQueues_FullMethodName = "/API.API/ListQueues" )
Variables ¶
var ( Status_name = map[int32]string{ 0: "SUCCESS", 1: "FAILURE", 2: "UNKNOWN", } Status_value = map[string]int32{ "SUCCESS": 0, "FAILURE": 1, "UNKNOWN": 2, } )
Enum value maps for Status.
var API_ServiceDesc = grpc.ServiceDesc{ ServiceName: "API.API", HandlerType: (*APIServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Healthz", Handler: _API_Healthz_Handler, }, { MethodName: "PushTask", Handler: _API_PushTask_Handler, }, { MethodName: "LoadTask", Handler: _API_LoadTask_Handler, }, { MethodName: "HeartBeat", Handler: _API_HeartBeat_Handler, }, { MethodName: "Complete", Handler: _API_Complete_Handler, }, { MethodName: "Fail", Handler: _API_Fail_Handler, }, { MethodName: "Progress", Handler: _API_Progress_Handler, }, { MethodName: "Peek", Handler: _API_Peek_Handler, }, { MethodName: "ListQueues", Handler: _API_ListQueues_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "api.proto", }
API_ServiceDesc is the grpc.ServiceDesc for API service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_api_proto protoreflect.FileDescriptor
Functions ¶
func RegisterAPIHandler ¶
RegisterAPIHandler registers the http handlers for service API to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterAPIHandlerClient ¶
RegisterAPIHandlerClient registers the http handlers for service API to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "APIClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "APIClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "APIClient" to call the correct interceptors.
func RegisterAPIHandlerFromEndpoint ¶
func RegisterAPIHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterAPIHandlerFromEndpoint is same as RegisterAPIHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterAPIHandlerServer ¶
RegisterAPIHandlerServer registers the http handlers for service API to "mux". UnaryRPC :call APIServer 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 RegisterAPIHandlerFromEndpoint instead.
func RegisterAPIServer ¶
func RegisterAPIServer(s grpc.ServiceRegistrar, srv APIServer)
Types ¶
type APIClient ¶
type APIClient interface { Healthz(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*StatusMessage, error) PushTask(ctx context.Context, in *Task, opts ...grpc.CallOption) (*StatusMessage, error) LoadTask(ctx context.Context, in *RequestMessage, opts ...grpc.CallOption) (*Task, error) HeartBeat(ctx context.Context, in *Task, opts ...grpc.CallOption) (*StatusMessage, error) Complete(ctx context.Context, in *Task, opts ...grpc.CallOption) (*StatusMessage, error) Fail(ctx context.Context, in *Task, opts ...grpc.CallOption) (*StatusMessage, error) Progress(ctx context.Context, in *RequestMessage, opts ...grpc.CallOption) (*QueueProgress, error) Peek(ctx context.Context, in *RequestMessage, opts ...grpc.CallOption) (*TaskList, error) ListQueues(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*QueueMap, error) }
APIClient is the client API for API 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 NewAPIClient ¶
func NewAPIClient(cc grpc.ClientConnInterface) APIClient
type APIServer ¶
type APIServer interface { Healthz(context.Context, *emptypb.Empty) (*StatusMessage, error) PushTask(context.Context, *Task) (*StatusMessage, error) LoadTask(context.Context, *RequestMessage) (*Task, error) HeartBeat(context.Context, *Task) (*StatusMessage, error) Complete(context.Context, *Task) (*StatusMessage, error) Fail(context.Context, *Task) (*StatusMessage, error) Progress(context.Context, *RequestMessage) (*QueueProgress, error) Peek(context.Context, *RequestMessage) (*TaskList, error) ListQueues(context.Context, *emptypb.Empty) (*QueueMap, error) // contains filtered or unexported methods }
APIServer is the server API for API service. All implementations must embed UnimplementedAPIServer for forward compatibility
type Meta ¶
type Meta struct { QueueID string `protobuf:"bytes,1,opt,name=queueID,proto3" json:"queueID,omitempty"` // contains filtered or unexported fields }
func (*Meta) Descriptor
deprecated
func (*Meta) GetQueueID ¶
func (*Meta) ProtoMessage ¶
func (*Meta) ProtoMessage()
func (*Meta) ProtoReflect ¶ added in v0.4.2
func (x *Meta) ProtoReflect() protoreflect.Message
type QueueMap ¶ added in v0.5.0
type QueueMap struct { TotalItems int32 `protobuf:"varint,1,opt,name=totalItems,proto3" json:"totalItems,omitempty"` Queues map[string]*QueueProgress `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
func (*QueueMap) Descriptor
deprecated
added in
v0.5.0
func (*QueueMap) GetQueues ¶ added in v0.5.0
func (x *QueueMap) GetQueues() map[string]*QueueProgress
func (*QueueMap) GetTotalItems ¶ added in v0.5.0
func (*QueueMap) ProtoMessage ¶ added in v0.5.0
func (*QueueMap) ProtoMessage()
func (*QueueMap) ProtoReflect ¶ added in v0.5.0
func (x *QueueMap) ProtoReflect() protoreflect.Message
type QueueProgress ¶
type QueueProgress struct { IncomingCount int32 `protobuf:"varint,1,opt,name=incomingCount,proto3" json:"incomingCount,omitempty"` ReceivedCount int32 `protobuf:"varint,2,opt,name=receivedCount,proto3" json:"receivedCount,omitempty"` RunningCount int32 `protobuf:"varint,3,opt,name=runningCount,proto3" json:"runningCount,omitempty"` ExpiredCount int32 `protobuf:"varint,4,opt,name=expiredCount,proto3" json:"expiredCount,omitempty"` CompletedCount int32 `protobuf:"varint,5,opt,name=completedCount,proto3" json:"completedCount,omitempty"` FailedCount int32 `protobuf:"varint,6,opt,name=failedCount,proto3" json:"failedCount,omitempty"` // contains filtered or unexported fields }
func (*QueueProgress) Descriptor
deprecated
func (*QueueProgress) Descriptor() ([]byte, []int)
Deprecated: Use QueueProgress.ProtoReflect.Descriptor instead.
func (*QueueProgress) GetCompletedCount ¶
func (x *QueueProgress) GetCompletedCount() int32
func (*QueueProgress) GetExpiredCount ¶
func (x *QueueProgress) GetExpiredCount() int32
func (*QueueProgress) GetFailedCount ¶
func (x *QueueProgress) GetFailedCount() int32
func (*QueueProgress) GetIncomingCount ¶
func (x *QueueProgress) GetIncomingCount() int32
func (*QueueProgress) GetReceivedCount ¶
func (x *QueueProgress) GetReceivedCount() int32
func (*QueueProgress) GetRunningCount ¶
func (x *QueueProgress) GetRunningCount() int32
func (*QueueProgress) ProtoMessage ¶
func (*QueueProgress) ProtoMessage()
func (*QueueProgress) ProtoReflect ¶ added in v0.4.2
func (x *QueueProgress) ProtoReflect() protoreflect.Message
func (*QueueProgress) Reset ¶
func (x *QueueProgress) Reset()
func (*QueueProgress) String ¶
func (x *QueueProgress) String() string
type RequestMessage ¶
type RequestMessage struct { QueueID string `protobuf:"bytes,1,opt,name=queueID,proto3" json:"queueID,omitempty"` ExpirationSec int32 `protobuf:"varint,2,opt,name=expirationSec,proto3" json:"expirationSec,omitempty"` Phase string `protobuf:"bytes,3,opt,name=phase,proto3" json:"phase,omitempty"` // only valid for peek Limit int32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` // only valid for peek // contains filtered or unexported fields }
func (*RequestMessage) Descriptor
deprecated
func (*RequestMessage) Descriptor() ([]byte, []int)
Deprecated: Use RequestMessage.ProtoReflect.Descriptor instead.
func (*RequestMessage) GetExpirationSec ¶
func (x *RequestMessage) GetExpirationSec() int32
func (*RequestMessage) GetLimit ¶
func (x *RequestMessage) GetLimit() int32
func (*RequestMessage) GetPhase ¶
func (x *RequestMessage) GetPhase() string
func (*RequestMessage) GetQueueID ¶
func (x *RequestMessage) GetQueueID() string
func (*RequestMessage) ProtoMessage ¶
func (*RequestMessage) ProtoMessage()
func (*RequestMessage) ProtoReflect ¶ added in v0.4.2
func (x *RequestMessage) ProtoReflect() protoreflect.Message
func (*RequestMessage) Reset ¶
func (x *RequestMessage) Reset()
func (*RequestMessage) String ¶
func (x *RequestMessage) String() string
type Status ¶
type Status int32
func (Status) Descriptor ¶ added in v0.4.2
func (Status) Descriptor() protoreflect.EnumDescriptor
func (Status) EnumDescriptor
deprecated
func (Status) Number ¶ added in v0.4.2
func (x Status) Number() protoreflect.EnumNumber
func (Status) Type ¶ added in v0.4.2
func (Status) Type() protoreflect.EnumType
type StatusMessage ¶
type StatusMessage struct { Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=API.Status" json:"status,omitempty"` Detail string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"` // contains filtered or unexported fields }
func (*StatusMessage) Descriptor
deprecated
func (*StatusMessage) Descriptor() ([]byte, []int)
Deprecated: Use StatusMessage.ProtoReflect.Descriptor instead.
func (*StatusMessage) GetDetail ¶
func (x *StatusMessage) GetDetail() string
func (*StatusMessage) GetStatus ¶
func (x *StatusMessage) GetStatus() Status
func (*StatusMessage) ProtoMessage ¶
func (*StatusMessage) ProtoMessage()
func (*StatusMessage) ProtoReflect ¶ added in v0.4.2
func (x *StatusMessage) ProtoReflect() protoreflect.Message
func (*StatusMessage) Reset ¶
func (x *StatusMessage) Reset()
func (*StatusMessage) String ¶
func (x *StatusMessage) String() string
type Task ¶
type Task struct { // reserved 1; // we took queueID out // reserved "queueID"; QueueID string `protobuf:"bytes,1,opt,name=queueID,proto3" json:"queueID,omitempty"` // needed to pass the queueID to push task to TaskID string `protobuf:"bytes,2,opt,name=taskID,proto3" json:"taskID,omitempty"` Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"` // perhaps should be called argument(s) Envs []string `protobuf:"bytes,4,rep,name=envs,proto3" json:"envs,omitempty"` ExpirationSec int32 `protobuf:"varint,5,opt,name=expirationSec,proto3" json:"expirationSec,omitempty"` // this is used to heartbeat // contains filtered or unexported fields }
Task is the definition of a task
func (*Task) Descriptor
deprecated
func (*Task) GetExpirationSec ¶
func (*Task) GetQueueID ¶
func (*Task) ProtoMessage ¶
func (*Task) ProtoMessage()
func (*Task) ProtoReflect ¶ added in v0.4.2
func (x *Task) ProtoReflect() protoreflect.Message
type TaskList ¶
type TaskList struct { TotalItems int32 `protobuf:"varint,1,opt,name=totalItems,proto3" json:"totalItems,omitempty"` Tasks []*Task `protobuf:"bytes,2,rep,name=tasks,proto3" json:"tasks,omitempty"` // contains filtered or unexported fields }
func (*TaskList) Descriptor
deprecated
func (*TaskList) GetTotalItems ¶
func (*TaskList) ProtoMessage ¶
func (*TaskList) ProtoMessage()
func (*TaskList) ProtoReflect ¶ added in v0.4.2
func (x *TaskList) ProtoReflect() protoreflect.Message
type UnimplementedAPIServer ¶
type UnimplementedAPIServer struct { }
UnimplementedAPIServer must be embedded to have forward compatible implementations.
func (UnimplementedAPIServer) Complete ¶
func (UnimplementedAPIServer) Complete(context.Context, *Task) (*StatusMessage, error)
func (UnimplementedAPIServer) Fail ¶ added in v0.4.2
func (UnimplementedAPIServer) Fail(context.Context, *Task) (*StatusMessage, error)
func (UnimplementedAPIServer) Healthz ¶
func (UnimplementedAPIServer) Healthz(context.Context, *emptypb.Empty) (*StatusMessage, error)
func (UnimplementedAPIServer) HeartBeat ¶
func (UnimplementedAPIServer) HeartBeat(context.Context, *Task) (*StatusMessage, error)
func (UnimplementedAPIServer) ListQueues ¶ added in v0.4.2
func (UnimplementedAPIServer) LoadTask ¶
func (UnimplementedAPIServer) LoadTask(context.Context, *RequestMessage) (*Task, error)
func (UnimplementedAPIServer) Peek ¶
func (UnimplementedAPIServer) Peek(context.Context, *RequestMessage) (*TaskList, error)
func (UnimplementedAPIServer) Progress ¶
func (UnimplementedAPIServer) Progress(context.Context, *RequestMessage) (*QueueProgress, error)
func (UnimplementedAPIServer) PushTask ¶
func (UnimplementedAPIServer) PushTask(context.Context, *Task) (*StatusMessage, error)
type UnsafeAPIServer ¶ added in v0.4.2
type UnsafeAPIServer interface {
// contains filtered or unexported methods
}
UnsafeAPIServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to APIServer will result in compilation errors.