wip: grpc api

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2017-08-14 08:39:37 -04:00
parent 1dd748e3f2
commit 2eba8d6511
No known key found for this signature in database
GPG key ID: A519480096146526
174 changed files with 22012 additions and 11410 deletions

Binary file not shown.

View file

@ -0,0 +1 @@
package configuration

View file

@ -0,0 +1,221 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/ehazlett/element/api/services/configuration/service.proto
/*
Package configuration is a generated protocol buffer package.
It is generated from these files:
github.com/ehazlett/element/api/services/configuration/service.proto
It has these top-level messages:
CreateServiceRequest
CreateServiceResponse
ListServicesRequest
ListServicesResponse
*/
package configuration
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import element_v1_types "github.com/ehazlett/element/api/types"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CreateServiceRequest struct {
Service *element_v1_types.Service `protobuf:"bytes,1,opt,name=service" json:"service,omitempty"`
}
func (m *CreateServiceRequest) Reset() { *m = CreateServiceRequest{} }
func (m *CreateServiceRequest) String() string { return proto.CompactTextString(m) }
func (*CreateServiceRequest) ProtoMessage() {}
func (*CreateServiceRequest) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{0} }
func (m *CreateServiceRequest) GetService() *element_v1_types.Service {
if m != nil {
return m.Service
}
return nil
}
type CreateServiceResponse struct {
}
func (m *CreateServiceResponse) Reset() { *m = CreateServiceResponse{} }
func (m *CreateServiceResponse) String() string { return proto.CompactTextString(m) }
func (*CreateServiceResponse) ProtoMessage() {}
func (*CreateServiceResponse) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{1} }
type ListServicesRequest struct {
}
func (m *ListServicesRequest) Reset() { *m = ListServicesRequest{} }
func (m *ListServicesRequest) String() string { return proto.CompactTextString(m) }
func (*ListServicesRequest) ProtoMessage() {}
func (*ListServicesRequest) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{2} }
type ListServicesResponse struct {
Services []*element_v1_types.Service `protobuf:"bytes,1,rep,name=services" json:"services,omitempty"`
}
func (m *ListServicesResponse) Reset() { *m = ListServicesResponse{} }
func (m *ListServicesResponse) String() string { return proto.CompactTextString(m) }
func (*ListServicesResponse) ProtoMessage() {}
func (*ListServicesResponse) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{3} }
func (m *ListServicesResponse) GetServices() []*element_v1_types.Service {
if m != nil {
return m.Services
}
return nil
}
func init() {
proto.RegisterType((*CreateServiceRequest)(nil), "element.v1.configuration.CreateServiceRequest")
proto.RegisterType((*CreateServiceResponse)(nil), "element.v1.configuration.CreateServiceResponse")
proto.RegisterType((*ListServicesRequest)(nil), "element.v1.configuration.ListServicesRequest")
proto.RegisterType((*ListServicesResponse)(nil), "element.v1.configuration.ListServicesResponse")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for Configuration service
type ConfigurationClient interface {
CreateService(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*CreateServiceResponse, error)
ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesResponse, error)
}
type configurationClient struct {
cc *grpc.ClientConn
}
func NewConfigurationClient(cc *grpc.ClientConn) ConfigurationClient {
return &configurationClient{cc}
}
func (c *configurationClient) CreateService(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*CreateServiceResponse, error) {
out := new(CreateServiceResponse)
err := grpc.Invoke(ctx, "/element.v1.configuration.Configuration/CreateService", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *configurationClient) ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesResponse, error) {
out := new(ListServicesResponse)
err := grpc.Invoke(ctx, "/element.v1.configuration.Configuration/ListServices", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Configuration service
type ConfigurationServer interface {
CreateService(context.Context, *CreateServiceRequest) (*CreateServiceResponse, error)
ListServices(context.Context, *ListServicesRequest) (*ListServicesResponse, error)
}
func RegisterConfigurationServer(s *grpc.Server, srv ConfigurationServer) {
s.RegisterService(&_Configuration_serviceDesc, srv)
}
func _Configuration_CreateService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateServiceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigurationServer).CreateService(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/element.v1.configuration.Configuration/CreateService",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigurationServer).CreateService(ctx, req.(*CreateServiceRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Configuration_ListServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListServicesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigurationServer).ListServices(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/element.v1.configuration.Configuration/ListServices",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigurationServer).ListServices(ctx, req.(*ListServicesRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Configuration_serviceDesc = grpc.ServiceDesc{
ServiceName: "element.v1.configuration.Configuration",
HandlerType: (*ConfigurationServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateService",
Handler: _Configuration_CreateService_Handler,
},
{
MethodName: "ListServices",
Handler: _Configuration_ListServices_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "github.com/ehazlett/element/api/services/configuration/service.proto",
}
func init() {
proto.RegisterFile("github.com/ehazlett/element/api/services/configuration/service.proto", fileDescriptorService)
}
var fileDescriptorService = []byte{
// 253 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4e, 0xc3, 0x30,
0x10, 0x44, 0x89, 0x90, 0x00, 0x2d, 0xf4, 0x62, 0x5a, 0x11, 0x72, 0xaa, 0x72, 0xe2, 0xc2, 0x5a,
0x34, 0xe2, 0x0b, 0xca, 0x0d, 0xb8, 0xc0, 0x17, 0xa4, 0xd1, 0xd2, 0x5a, 0x6a, 0x63, 0xe3, 0xdd,
0x54, 0x82, 0xef, 0xe6, 0x03, 0x90, 0x5a, 0x1b, 0xc5, 0xa8, 0x85, 0x5e, 0x47, 0x6f, 0x67, 0x3c,
0x63, 0x78, 0x98, 0x1b, 0x59, 0x74, 0x33, 0x6c, 0xec, 0x4a, 0xd3, 0xa2, 0xfe, 0x5c, 0x92, 0x88,
0xa6, 0x25, 0xad, 0xa8, 0x15, 0x5d, 0x3b, 0xa3, 0x99, 0xfc, 0xda, 0x34, 0xc4, 0xba, 0xb1, 0xed,
0x9b, 0x99, 0x77, 0xbe, 0x16, 0x63, 0xdb, 0x28, 0xa3, 0xf3, 0x56, 0xac, 0xca, 0xc3, 0x05, 0xae,
0xef, 0x30, 0xe1, 0x8a, 0xea, 0x3f, 0x7f, 0xf9, 0x70, 0xc4, 0xa9, 0x5d, 0xf9, 0x08, 0xc3, 0xa9,
0xa7, 0x5a, 0xe8, 0x75, 0x2b, 0xbf, 0xd0, 0x7b, 0x47, 0x2c, 0xaa, 0x82, 0xd3, 0x00, 0xe6, 0xd9,
0x38, 0xbb, 0x39, 0x9f, 0x5c, 0x63, 0x2f, 0x78, 0xe3, 0x84, 0xf1, 0x24, 0x92, 0xe5, 0x15, 0x8c,
0x7e, 0x99, 0xb1, 0xb3, 0x2d, 0x53, 0x39, 0x82, 0xcb, 0x27, 0xc3, 0x12, 0x64, 0x0e, 0x21, 0xe5,
0x33, 0x0c, 0x53, 0x79, 0x8b, 0xab, 0x7b, 0x38, 0x8b, 0x5b, 0xe4, 0xd9, 0xf8, 0xf8, 0xef, 0xf4,
0x1f, 0x74, 0xf2, 0x95, 0xc1, 0x60, 0xda, 0x9f, 0x44, 0x79, 0x18, 0x24, 0x0f, 0x52, 0x88, 0xfb,
0xe6, 0xc3, 0x5d, 0x33, 0x14, 0xfa, 0x60, 0x3e, 0x34, 0x3d, 0x52, 0x16, 0x2e, 0xfa, 0xa5, 0xd4,
0xed, 0x7e, 0x8b, 0x1d, 0x9b, 0x14, 0x78, 0x28, 0x1e, 0x03, 0x67, 0x27, 0x9b, 0x9f, 0xac, 0xbe,
0x03, 0x00, 0x00, 0xff, 0xff, 0x5d, 0x1c, 0x1e, 0x12, 0x60, 0x02, 0x00, 0x00,
}

View file

@ -0,0 +1,20 @@
syntax = "proto3";
package element.v1.configuration;
import "github.com/ehazlett/element/api/types/service.proto";
service Configuration {
rpc CreateService(CreateServiceRequest) returns (CreateServiceResponse) {}
rpc ListServices(ListServicesRequest) returns (ListServicesResponse) {}
}
message CreateServiceRequest {
element.v1.types.Service service = 1;
}
message CreateServiceResponse {}
message ListServicesRequest {}
message ListServicesResponse{
repeated element.v1.types.Service services = 1;
}

1
api/types/doc.go Normal file
View file

@ -0,0 +1 @@
package types

151
api/types/service.pb.go Normal file
View file

@ -0,0 +1,151 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/ehazlett/element/api/types/service.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
github.com/ehazlett/element/api/types/service.proto
It has these top-level messages:
Service
RuntimeSpec
*/
package types
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Service struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Hosts []string `protobuf:"bytes,2,rep,name=hosts" json:"hosts,omitempty"`
RuntimeSpec *RuntimeSpec `protobuf:"bytes,3,opt,name=runtime_spec,json=runtimeSpec" json:"runtime_spec,omitempty"`
}
func (m *Service) Reset() { *m = Service{} }
func (m *Service) String() string { return proto.CompactTextString(m) }
func (*Service) ProtoMessage() {}
func (*Service) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{0} }
func (m *Service) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *Service) GetHosts() []string {
if m != nil {
return m.Hosts
}
return nil
}
func (m *Service) GetRuntimeSpec() *RuntimeSpec {
if m != nil {
return m.RuntimeSpec
}
return nil
}
type RuntimeSpec struct {
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"`
Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"`
Runtime string `protobuf:"bytes,4,opt,name=runtime,proto3" json:"runtime,omitempty"`
Port uint64 `protobuf:"varint,5,opt,name=port,proto3" json:"port,omitempty"`
Labels map[string]string `protobuf:"bytes,6,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (m *RuntimeSpec) Reset() { *m = RuntimeSpec{} }
func (m *RuntimeSpec) String() string { return proto.CompactTextString(m) }
func (*RuntimeSpec) ProtoMessage() {}
func (*RuntimeSpec) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{1} }
func (m *RuntimeSpec) GetNamespace() string {
if m != nil {
return m.Namespace
}
return ""
}
func (m *RuntimeSpec) GetImage() string {
if m != nil {
return m.Image
}
return ""
}
func (m *RuntimeSpec) GetProtocol() string {
if m != nil {
return m.Protocol
}
return ""
}
func (m *RuntimeSpec) GetRuntime() string {
if m != nil {
return m.Runtime
}
return ""
}
func (m *RuntimeSpec) GetPort() uint64 {
if m != nil {
return m.Port
}
return 0
}
func (m *RuntimeSpec) GetLabels() map[string]string {
if m != nil {
return m.Labels
}
return nil
}
func init() {
proto.RegisterType((*Service)(nil), "element.v1.types.Service")
proto.RegisterType((*RuntimeSpec)(nil), "element.v1.types.RuntimeSpec")
}
func init() {
proto.RegisterFile("github.com/ehazlett/element/api/types/service.proto", fileDescriptorService)
}
var fileDescriptorService = []byte{
// 320 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x8f, 0xb1, 0x4e, 0xc3, 0x30,
0x10, 0x86, 0x15, 0xa7, 0x4d, 0x89, 0xc3, 0x50, 0x59, 0x15, 0xb2, 0x2a, 0x10, 0x51, 0xa7, 0xb0,
0x38, 0xa2, 0x5d, 0x80, 0x09, 0x10, 0x0c, 0x48, 0x4c, 0xee, 0x03, 0x20, 0x37, 0x3d, 0xa5, 0x16,
0x49, 0x6c, 0xc5, 0x6e, 0xa5, 0xf0, 0x06, 0xbc, 0x24, 0x03, 0x4f, 0x82, 0xe2, 0x84, 0xb6, 0x62,
0x60, 0xbb, 0xef, 0xfe, 0xff, 0x74, 0xff, 0x8f, 0x17, 0xb9, 0xb4, 0x9b, 0xed, 0x8a, 0x65, 0xaa,
0x4c, 0x61, 0x23, 0x3e, 0x0a, 0xb0, 0x36, 0x85, 0x02, 0x4a, 0xa8, 0x6c, 0x2a, 0xb4, 0x4c, 0x6d,
0xa3, 0xc1, 0xa4, 0x06, 0xea, 0x9d, 0xcc, 0x80, 0xe9, 0x5a, 0x59, 0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0x61, 0x27, 0x8a, 0xed, 0xbe, 0x83, 0x83, 0x3b, 0x74, 0xe3, 0xad, 0x02,
0x97, 0x7a, 0xf1, 0x13, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xda, 0x2d, 0xa9, 0xec, 0x01, 0x00, 0x00,
}

20
api/types/service.proto Normal file
View file

@ -0,0 +1,20 @@
syntax = "proto3";
package element.v1.types;
import "gogoproto/gogo.proto";
message Service {
string id = 1 [(gogoproto.customname) = "ID"];
repeated string hosts = 2;
RuntimeSpec runtime_spec = 3;
}
message RuntimeSpec {
string namespace = 1;
string image = 2;
string protocol = 3;
string runtime = 4;
uint64 port = 5;
map<string, string> labels = 6;
}