api

package
v0.0.0-...-13bbb49 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT 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 IntercomType_name = map[int32]string{
	0: "INTERCOM_TYPE_ASK_TASK",
	1: "INTERCOM_TYPE_FINISH_MAP_TASK",
	2: "INTERCOM_TYPE_FINISH_REDUCE_TASK",
	3: "INTERCOM_TYPE_SEND_INTER_FILE",
}
View Source
var IntercomType_value = map[string]int32{
	"INTERCOM_TYPE_ASK_TASK":           0,
	"INTERCOM_TYPE_FINISH_MAP_TASK":    1,
	"INTERCOM_TYPE_FINISH_REDUCE_TASK": 2,
	"INTERCOM_TYPE_SEND_INTER_FILE":    3,
}
View Source
var TaskStatus_name = map[int32]string{
	0: "TASK_STATUS_UNALLOTED",
	1: "TASK_STATUS_ALLOTED",
	2: "TASK_STATUS_DONE",
}
View Source
var TaskStatus_value = map[string]int32{
	"TASK_STATUS_UNALLOTED": 0,
	"TASK_STATUS_ALLOTED":   1,
	"TASK_STATUS_DONE":      2,
}
View Source
var TaskType_name = map[int32]string{
	0: "TASK_TYPE_MAP",
	1: "TASK_TYPE_REDUCE",
}
View Source
var TaskType_value = map[string]int32{
	"TASK_TYPE_MAP":    0,
	"TASK_TYPE_REDUCE": 1,
}
View Source
var WorkerStatus_name = map[int32]string{
	0: "WORKER_STATUS_ALIVE",
	1: "WORKER_STATUS_UNHEALTHY",
}
View Source
var WorkerStatus_value = map[string]int32{
	"WORKER_STATUS_ALIVE":     0,
	"WORKER_STATUS_UNHEALTHY": 1,
}

Functions

func RegisterMapReduceRPCServiceHandler

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

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

func RegisterMapReduceRPCServiceHandlerClient

func RegisterMapReduceRPCServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MapReduceRPCServiceClient) error

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

func RegisterMapReduceRPCServiceHandlerFromEndpoint

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

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

func RegisterMapReduceRPCServiceHandlerServer

func RegisterMapReduceRPCServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MapReduceRPCServiceServer) error

RegisterMapReduceRPCServiceHandlerServer registers the http handlers for service MapReduceRPCService to "mux". UnaryRPC :call MapReduceRPCServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterMapReduceRPCServiceServer

func RegisterMapReduceRPCServiceServer(s *grpc.Server, srv MapReduceRPCServiceServer)

Types

type AddTaskRequest

type AddTaskRequest struct {
	Task                 *Task    `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

---------- request + response ----------

func (*AddTaskRequest) Descriptor

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

func (*AddTaskRequest) GetTask

func (m *AddTaskRequest) GetTask() *Task

func (*AddTaskRequest) ProtoMessage

func (*AddTaskRequest) ProtoMessage()

func (*AddTaskRequest) Reset

func (m *AddTaskRequest) Reset()

func (*AddTaskRequest) String

func (m *AddTaskRequest) String() string

func (*AddTaskRequest) XXX_DiscardUnknown

func (m *AddTaskRequest) XXX_DiscardUnknown()

func (*AddTaskRequest) XXX_Marshal

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

func (*AddTaskRequest) XXX_Merge

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

func (*AddTaskRequest) XXX_Size

func (m *AddTaskRequest) XXX_Size() int

func (*AddTaskRequest) XXX_Unmarshal

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

type AddTaskResponse

type AddTaskResponse struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*AddTaskResponse) Descriptor

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

func (*AddTaskResponse) ProtoMessage

func (*AddTaskResponse) ProtoMessage()

func (*AddTaskResponse) Reset

func (m *AddTaskResponse) Reset()

func (*AddTaskResponse) String

func (m *AddTaskResponse) String() string

func (*AddTaskResponse) XXX_DiscardUnknown

func (m *AddTaskResponse) XXX_DiscardUnknown()

func (*AddTaskResponse) XXX_Marshal

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

func (*AddTaskResponse) XXX_Merge

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

func (*AddTaskResponse) XXX_Size

func (m *AddTaskResponse) XXX_Size() int

func (*AddTaskResponse) XXX_Unmarshal

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

type IntercomRequest

type IntercomRequest struct {
	MsgType              IntercomType `protobuf:"varint,1,opt,name=MsgType,proto3,enum=amazingchow.mapreduce.IntercomType" json:"MsgType,omitempty"`
	MsgContent           string       `protobuf:"bytes,2,opt,name=MsgContent,proto3" json:"MsgContent,omitempty"`
	Extra                string       `protobuf:"bytes,3,opt,name=Extra,proto3" json:"Extra,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

func (*IntercomRequest) Descriptor

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

func (*IntercomRequest) GetExtra

func (m *IntercomRequest) GetExtra() string

func (*IntercomRequest) GetMsgContent

func (m *IntercomRequest) GetMsgContent() string

func (*IntercomRequest) GetMsgType

func (m *IntercomRequest) GetMsgType() IntercomType

func (*IntercomRequest) ProtoMessage

func (*IntercomRequest) ProtoMessage()

func (*IntercomRequest) Reset

func (m *IntercomRequest) Reset()

func (*IntercomRequest) String

func (m *IntercomRequest) String() string

func (*IntercomRequest) XXX_DiscardUnknown

func (m *IntercomRequest) XXX_DiscardUnknown()

func (*IntercomRequest) XXX_Marshal

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

func (*IntercomRequest) XXX_Merge

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

func (*IntercomRequest) XXX_Size

func (m *IntercomRequest) XXX_Size() int

func (*IntercomRequest) XXX_Unmarshal

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

type IntercomResponse

type IntercomResponse struct {
	TaskType             TaskType `protobuf:"varint,1,opt,name=TaskType,proto3,enum=amazingchow.mapreduce.TaskType" json:"TaskType,omitempty"`
	File                 string   `protobuf:"bytes,2,opt,name=File,proto3" json:"File,omitempty"`
	NReduce              int32    `protobuf:"varint,3,opt,name=NReduce,proto3" json:"NReduce,omitempty"`
	MapTaskAllocated     int32    `protobuf:"varint,4,opt,name=MapTaskAllocated,proto3" json:"MapTaskAllocated,omitempty"`
	ReduceTaskAllocated  int32    `protobuf:"varint,5,opt,name=ReduceTaskAllocated,proto3" json:"ReduceTaskAllocated,omitempty"`
	ReduceFiles          []string `protobuf:"bytes,6,rep,name=ReduceFiles,proto3" json:"ReduceFiles,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*IntercomResponse) Descriptor

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

func (*IntercomResponse) GetFile

func (m *IntercomResponse) GetFile() string

func (*IntercomResponse) GetMapTaskAllocated

func (m *IntercomResponse) GetMapTaskAllocated() int32

func (*IntercomResponse) GetNReduce

func (m *IntercomResponse) GetNReduce() int32

func (*IntercomResponse) GetReduceFiles

func (m *IntercomResponse) GetReduceFiles() []string

func (*IntercomResponse) GetReduceTaskAllocated

func (m *IntercomResponse) GetReduceTaskAllocated() int32

func (*IntercomResponse) GetTaskType

func (m *IntercomResponse) GetTaskType() TaskType

func (*IntercomResponse) ProtoMessage

func (*IntercomResponse) ProtoMessage()

func (*IntercomResponse) Reset

func (m *IntercomResponse) Reset()

func (*IntercomResponse) String

func (m *IntercomResponse) String() string

func (*IntercomResponse) XXX_DiscardUnknown

func (m *IntercomResponse) XXX_DiscardUnknown()

func (*IntercomResponse) XXX_Marshal

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

func (*IntercomResponse) XXX_Merge

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

func (*IntercomResponse) XXX_Size

func (m *IntercomResponse) XXX_Size() int

func (*IntercomResponse) XXX_Unmarshal

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

type IntercomType

type IntercomType int32
const (
	IntercomType_INTERCOM_TYPE_ASK_TASK           IntercomType = 0
	IntercomType_INTERCOM_TYPE_FINISH_MAP_TASK    IntercomType = 1
	IntercomType_INTERCOM_TYPE_FINISH_REDUCE_TASK IntercomType = 2
	IntercomType_INTERCOM_TYPE_SEND_INTER_FILE    IntercomType = 3
)

func (IntercomType) EnumDescriptor

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

func (IntercomType) String

func (x IntercomType) String() string

type ListWorkersRequest

type ListWorkersRequest struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ListWorkersRequest) Descriptor

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

func (*ListWorkersRequest) ProtoMessage

func (*ListWorkersRequest) ProtoMessage()

func (*ListWorkersRequest) Reset

func (m *ListWorkersRequest) Reset()

func (*ListWorkersRequest) String

func (m *ListWorkersRequest) String() string

func (*ListWorkersRequest) XXX_DiscardUnknown

func (m *ListWorkersRequest) XXX_DiscardUnknown()

func (*ListWorkersRequest) XXX_Marshal

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

func (*ListWorkersRequest) XXX_Merge

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

func (*ListWorkersRequest) XXX_Size

func (m *ListWorkersRequest) XXX_Size() int

func (*ListWorkersRequest) XXX_Unmarshal

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

type ListWorkersResponse

type ListWorkersResponse struct {
	Workers              []*Worker `protobuf:"bytes,1,rep,name=workers,proto3" json:"workers,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*ListWorkersResponse) Descriptor

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

func (*ListWorkersResponse) GetWorkers

func (m *ListWorkersResponse) GetWorkers() []*Worker

func (*ListWorkersResponse) ProtoMessage

func (*ListWorkersResponse) ProtoMessage()

func (*ListWorkersResponse) Reset

func (m *ListWorkersResponse) Reset()

func (*ListWorkersResponse) String

func (m *ListWorkersResponse) String() string

func (*ListWorkersResponse) XXX_DiscardUnknown

func (m *ListWorkersResponse) XXX_DiscardUnknown()

func (*ListWorkersResponse) XXX_Marshal

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

func (*ListWorkersResponse) XXX_Merge

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

func (*ListWorkersResponse) XXX_Size

func (m *ListWorkersResponse) XXX_Size() int

func (*ListWorkersResponse) XXX_Unmarshal

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

type MapReduceRPCServiceClient

type MapReduceRPCServiceClient interface {
	AddTask(ctx context.Context, in *AddTaskRequest, opts ...grpc.CallOption) (*AddTaskResponse, error)
	ListWorkers(ctx context.Context, in *ListWorkersRequest, opts ...grpc.CallOption) (*ListWorkersResponse, error)
	Intercom(ctx context.Context, in *IntercomRequest, opts ...grpc.CallOption) (*IntercomResponse, error)
}

MapReduceRPCServiceClient is the client API for MapReduceRPCService service.

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

func NewMapReduceRPCServiceClient

func NewMapReduceRPCServiceClient(cc *grpc.ClientConn) MapReduceRPCServiceClient

type MapReduceRPCServiceServer

type MapReduceRPCServiceServer interface {
	AddTask(context.Context, *AddTaskRequest) (*AddTaskResponse, error)
	ListWorkers(context.Context, *ListWorkersRequest) (*ListWorkersResponse, error)
	Intercom(context.Context, *IntercomRequest) (*IntercomResponse, error)
}

MapReduceRPCServiceServer is the server API for MapReduceRPCService service.

type Task

type Task struct {
	Inputs               []string `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Task) Descriptor

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

func (*Task) GetInputs

func (m *Task) GetInputs() []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 TaskStatus

type TaskStatus int32
const (
	TaskStatus_TASK_STATUS_UNALLOTED TaskStatus = 0
	TaskStatus_TASK_STATUS_ALLOTED   TaskStatus = 1
	TaskStatus_TASK_STATUS_DONE      TaskStatus = 2
)

func (TaskStatus) EnumDescriptor

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

func (TaskStatus) String

func (x TaskStatus) String() string

type TaskType

type TaskType int32
const (
	TaskType_TASK_TYPE_MAP    TaskType = 0
	TaskType_TASK_TYPE_REDUCE TaskType = 1
)

func (TaskType) EnumDescriptor

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

func (TaskType) String

func (x TaskType) String() string

type UnimplementedMapReduceRPCServiceServer

type UnimplementedMapReduceRPCServiceServer struct {
}

UnimplementedMapReduceRPCServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedMapReduceRPCServiceServer) AddTask

func (*UnimplementedMapReduceRPCServiceServer) Intercom

func (*UnimplementedMapReduceRPCServiceServer) ListWorkers

type Worker

type Worker struct {
	Id                   string       `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Status               WorkerStatus `protobuf:"varint,5,opt,name=status,proto3,enum=amazingchow.mapreduce.WorkerStatus" json:"status,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

func (*Worker) Descriptor

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

func (*Worker) GetId

func (m *Worker) GetId() string

func (*Worker) GetStatus

func (m *Worker) GetStatus() WorkerStatus

func (*Worker) ProtoMessage

func (*Worker) ProtoMessage()

func (*Worker) Reset

func (m *Worker) Reset()

func (*Worker) String

func (m *Worker) String() string

func (*Worker) XXX_DiscardUnknown

func (m *Worker) XXX_DiscardUnknown()

func (*Worker) XXX_Marshal

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

func (*Worker) XXX_Merge

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

func (*Worker) XXX_Size

func (m *Worker) XXX_Size() int

func (*Worker) XXX_Unmarshal

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

type WorkerStatus

type WorkerStatus int32
const (
	WorkerStatus_WORKER_STATUS_ALIVE     WorkerStatus = 0
	WorkerStatus_WORKER_STATUS_UNHEALTHY WorkerStatus = 1
)

func (WorkerStatus) EnumDescriptor

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

func (WorkerStatus) String

func (x WorkerStatus) String() string

Jump to

Keyboard shortcuts

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