API

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 14 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 Status_name = map[int32]string{
	0: "SUCCESS",
	1: "FAILURE",
	2: "UNKNOWN",
}
View Source
var Status_value = map[string]int32{
	"SUCCESS": 0,
	"FAILURE": 1,
	"UNKNOWN": 2,
}

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, opts []grpc.DialOption) 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.

func RegisterAPIServer

func RegisterAPIServer(s *grpc.Server, srv APIServer)

Types

type APIClient

type APIClient interface {
	Healthz(ctx context.Context, in *empty.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)
	Progress(ctx context.Context, in *RequestMessage, opts ...grpc.CallOption) (*QueueProgress, error)
	Peek(ctx context.Context, in *RequestMessage, opts ...grpc.CallOption) (*TaskList, error)
}

APIClient is the client API for API service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewAPIClient

func NewAPIClient(cc *grpc.ClientConn) APIClient

type APIServer

APIServer is the server API for API service.

type Meta

type Meta struct {
	QueueID              string   `protobuf:"bytes,1,opt,name=queueID,proto3" json:"queueID,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Meta) Descriptor

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

func (*Meta) GetQueueID

func (m *Meta) GetQueueID() string

func (*Meta) ProtoMessage

func (*Meta) ProtoMessage()

func (*Meta) Reset

func (m *Meta) Reset()

func (*Meta) String

func (m *Meta) String() string

func (*Meta) XXX_DiscardUnknown

func (m *Meta) XXX_DiscardUnknown()

func (*Meta) XXX_Marshal

func (m *Meta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Meta) XXX_Merge

func (m *Meta) XXX_Merge(src proto.Message)

func (*Meta) XXX_Size

func (m *Meta) XXX_Size() int

func (*Meta) XXX_Unmarshal

func (m *Meta) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*QueueProgress) Descriptor

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

func (*QueueProgress) GetCompletedCount

func (m *QueueProgress) GetCompletedCount() int32

func (*QueueProgress) GetExpiredCount

func (m *QueueProgress) GetExpiredCount() int32

func (*QueueProgress) GetFailedCount

func (m *QueueProgress) GetFailedCount() int32

func (*QueueProgress) GetIncomingCount

func (m *QueueProgress) GetIncomingCount() int32

func (*QueueProgress) GetReceivedCount

func (m *QueueProgress) GetReceivedCount() int32

func (*QueueProgress) GetRunningCount

func (m *QueueProgress) GetRunningCount() int32

func (*QueueProgress) ProtoMessage

func (*QueueProgress) ProtoMessage()

func (*QueueProgress) Reset

func (m *QueueProgress) Reset()

func (*QueueProgress) String

func (m *QueueProgress) String() string

func (*QueueProgress) XXX_DiscardUnknown

func (m *QueueProgress) XXX_DiscardUnknown()

func (*QueueProgress) XXX_Marshal

func (m *QueueProgress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueueProgress) XXX_Merge

func (m *QueueProgress) XXX_Merge(src proto.Message)

func (*QueueProgress) XXX_Size

func (m *QueueProgress) XXX_Size() int

func (*QueueProgress) XXX_Unmarshal

func (m *QueueProgress) XXX_Unmarshal(b []byte) error

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"`
	Limit                int32    `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RequestMessage) Descriptor

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

func (*RequestMessage) GetExpirationSec

func (m *RequestMessage) GetExpirationSec() int32

func (*RequestMessage) GetLimit

func (m *RequestMessage) GetLimit() int32

func (*RequestMessage) GetPhase

func (m *RequestMessage) GetPhase() string

func (*RequestMessage) GetQueueID

func (m *RequestMessage) GetQueueID() string

func (*RequestMessage) ProtoMessage

func (*RequestMessage) ProtoMessage()

func (*RequestMessage) Reset

func (m *RequestMessage) Reset()

func (*RequestMessage) String

func (m *RequestMessage) String() string

func (*RequestMessage) XXX_DiscardUnknown

func (m *RequestMessage) XXX_DiscardUnknown()

func (*RequestMessage) XXX_Marshal

func (m *RequestMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RequestMessage) XXX_Merge

func (m *RequestMessage) XXX_Merge(src proto.Message)

func (*RequestMessage) XXX_Size

func (m *RequestMessage) XXX_Size() int

func (*RequestMessage) XXX_Unmarshal

func (m *RequestMessage) XXX_Unmarshal(b []byte) error

type Status

type Status int32
const (
	Status_SUCCESS Status = 0
	Status_FAILURE Status = 1
	Status_UNKNOWN Status = 2
)

func (Status) EnumDescriptor

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

func (Status) String

func (x Status) String() string

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StatusMessage) Descriptor

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

func (*StatusMessage) GetDetail

func (m *StatusMessage) GetDetail() string

func (*StatusMessage) GetStatus

func (m *StatusMessage) GetStatus() Status

func (*StatusMessage) ProtoMessage

func (*StatusMessage) ProtoMessage()

func (*StatusMessage) Reset

func (m *StatusMessage) Reset()

func (*StatusMessage) String

func (m *StatusMessage) String() string

func (*StatusMessage) XXX_DiscardUnknown

func (m *StatusMessage) XXX_DiscardUnknown()

func (*StatusMessage) XXX_Marshal

func (m *StatusMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StatusMessage) XXX_Merge

func (m *StatusMessage) XXX_Merge(src proto.Message)

func (*StatusMessage) XXX_Size

func (m *StatusMessage) XXX_Size() int

func (*StatusMessage) XXX_Unmarshal

func (m *StatusMessage) XXX_Unmarshal(b []byte) error

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"`
	TaskID               string   `protobuf:"bytes,2,opt,name=taskID,proto3" json:"taskID,omitempty"`
	Body                 string   `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
	Envs                 []string `protobuf:"bytes,4,rep,name=envs,proto3" json:"envs,omitempty"`
	ExpirationSec        int32    `protobuf:"varint,5,opt,name=expirationSec,proto3" json:"expirationSec,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Task is the definition of a task

func (*Task) Descriptor

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

func (*Task) GetBody

func (m *Task) GetBody() string

func (*Task) GetEnvs

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

func (*Task) GetExpirationSec

func (m *Task) GetExpirationSec() int32

func (*Task) GetQueueID

func (m *Task) GetQueueID() string

func (*Task) GetTaskID

func (m *Task) GetTaskID() string

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) Reset

func (m *Task) Reset()

func (*Task) String

func (m *Task) String() string

func (*Task) XXX_DiscardUnknown

func (m *Task) XXX_DiscardUnknown()

func (*Task) XXX_Marshal

func (m *Task) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Task) XXX_Merge

func (m *Task) XXX_Merge(src proto.Message)

func (*Task) XXX_Size

func (m *Task) XXX_Size() int

func (*Task) XXX_Unmarshal

func (m *Task) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TaskList) Descriptor

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

func (*TaskList) GetTasks

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

func (*TaskList) GetTotalItems

func (m *TaskList) GetTotalItems() int32

func (*TaskList) ProtoMessage

func (*TaskList) ProtoMessage()

func (*TaskList) Reset

func (m *TaskList) Reset()

func (*TaskList) String

func (m *TaskList) String() string

func (*TaskList) XXX_DiscardUnknown

func (m *TaskList) XXX_DiscardUnknown()

func (*TaskList) XXX_Marshal

func (m *TaskList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TaskList) XXX_Merge

func (m *TaskList) XXX_Merge(src proto.Message)

func (*TaskList) XXX_Size

func (m *TaskList) XXX_Size() int

func (*TaskList) XXX_Unmarshal

func (m *TaskList) XXX_Unmarshal(b []byte) error

type UnimplementedAPIServer

type UnimplementedAPIServer struct {
}

UnimplementedAPIServer can be embedded to have forward compatible implementations.

func (*UnimplementedAPIServer) Complete

func (*UnimplementedAPIServer) Complete(ctx context.Context, req *Task) (*StatusMessage, error)

func (*UnimplementedAPIServer) Healthz

func (*UnimplementedAPIServer) HeartBeat

func (*UnimplementedAPIServer) HeartBeat(ctx context.Context, req *Task) (*StatusMessage, error)

func (*UnimplementedAPIServer) LoadTask

func (*UnimplementedAPIServer) Peek

func (*UnimplementedAPIServer) Progress

func (*UnimplementedAPIServer) PushTask

func (*UnimplementedAPIServer) PushTask(ctx context.Context, req *Task) (*StatusMessage, error)

Jump to

Keyboard shortcuts

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