API

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package API is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
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

View Source
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.

View Source
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)

Functions

func RegisterAPIHandler

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

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

func RegisterAPIHandlerClient

func RegisterAPIHandlerClient(ctx context.Context, mux *runtime.ServeMux, client APIClient) error

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

func RegisterAPIHandlerServer(ctx context.Context, mux *runtime.ServeMux, server APIServer) error

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) Descriptor() ([]byte, []int)

Deprecated: Use Meta.ProtoReflect.Descriptor instead.

func (*Meta) GetQueueID

func (x *Meta) GetQueueID() string

func (*Meta) ProtoMessage

func (*Meta) ProtoMessage()

func (*Meta) ProtoReflect added in v0.4.2

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

func (*Meta) Reset

func (x *Meta) Reset()

func (*Meta) String

func (x *Meta) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use QueueMap.ProtoReflect.Descriptor instead.

func (*QueueMap) GetQueues added in v0.5.0

func (x *QueueMap) GetQueues() map[string]*QueueProgress

func (*QueueMap) GetTotalItems added in v0.5.0

func (x *QueueMap) GetTotalItems() int32

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

func (*QueueMap) Reset added in v0.5.0

func (x *QueueMap) Reset()

func (*QueueMap) String added in v0.5.0

func (x *QueueMap) String() string

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
const (
	Status_SUCCESS Status = 0
	Status_FAILURE Status = 1
	Status_UNKNOWN Status = 2
)

func (Status) Descriptor added in v0.4.2

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum added in v0.4.2

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

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

Deprecated: Use Status.Descriptor instead.

func (Status) Number added in v0.4.2

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Task.ProtoReflect.Descriptor instead.

func (*Task) GetBody

func (x *Task) GetBody() string

func (*Task) GetEnvs

func (x *Task) GetEnvs() []string

func (*Task) GetExpirationSec

func (x *Task) GetExpirationSec() int32

func (*Task) GetQueueID

func (x *Task) GetQueueID() string

func (*Task) GetTaskID

func (x *Task) GetTaskID() string

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) ProtoReflect added in v0.4.2

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

func (*Task) Reset

func (x *Task) Reset()

func (*Task) String

func (x *Task) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use TaskList.ProtoReflect.Descriptor instead.

func (*TaskList) GetTasks

func (x *TaskList) GetTasks() []*Task

func (*TaskList) GetTotalItems

func (x *TaskList) GetTotalItems() int32

func (*TaskList) ProtoMessage

func (*TaskList) ProtoMessage()

func (*TaskList) ProtoReflect added in v0.4.2

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

func (*TaskList) Reset

func (x *TaskList) Reset()

func (*TaskList) String

func (x *TaskList) String() string

type UnimplementedAPIServer

type UnimplementedAPIServer struct {
}

UnimplementedAPIServer must be embedded to have forward compatible implementations.

func (UnimplementedAPIServer) Complete

func (UnimplementedAPIServer) Fail added in v0.4.2

func (UnimplementedAPIServer) Healthz

func (UnimplementedAPIServer) HeartBeat

func (UnimplementedAPIServer) ListQueues added in v0.4.2

func (UnimplementedAPIServer) LoadTask

func (UnimplementedAPIServer) Peek

func (UnimplementedAPIServer) Progress

func (UnimplementedAPIServer) PushTask

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.

Jump to

Keyboard shortcuts

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