super

package module
v0.0.0-...-82c95b6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: MIT Imports: 22 Imported by: 0

README

This is just a dumping ground for a sample / dummy project.


MIT License

Copyright (c) 2018 Elliott Polk

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package super is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImmutableValue          = errors.New("attempting to edit immutable value")
	ErrInvalidRecordInfo       = errors.New("invalid record info")
	ErrInvalidCreatedBy        = errors.New("invalid created by value")
	ErrInvalidUpdatedBy        = errors.New("invalid updated by value")
	ErrDuplicateRecord         = errors.New("duplicate record for provided id")
	ErrNotFound                = errors.New("no valid record for provided id")
	ErrInvalidId               = errors.New("no valid id for provided record")
	ErrInvalidUsername         = errors.New("no valid username provided")
	ErrIncompleteAction        = errors.New("not all records were properly acted on")
	ErrMutlipleRecordsReturned = errors.New("multiple records returned")
	ErrNoMongoClient           = errors.New("no valid mongo client")
)
View Source
var RecordInfo_Status_name = map[int32]string{
	0: "draft",
	1: "active",
	2: "archived",
	3: "invalid",
}
View Source
var RecordInfo_Status_value = map[string]int32{
	"draft":    0,
	"active":   1,
	"archived": 2,
	"invalid":  3,
}

Functions

func Create

func Create(ctx context.Context, items []*Dope, db *mongo.Database) error

Create will validate fields for the provided records and attempt to create new Dope records in the datastore

func Delete

func Delete(ctx context.Context, user string, items []*Dope, db *mongo.Database) error

Delete ...

func RegisterDopeServiceHandler

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

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

func RegisterDopeServiceHandlerClient

func RegisterDopeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DopeServiceClient) error

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

func RegisterDopeServiceHandlerFromEndpoint

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

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

func RegisterDopeServiceServer

func RegisterDopeServiceServer(s *grpc.Server, srv DopeServiceServer)

func Update

func Update(ctx context.Context, user string, filter bson.D, items []*Dope, db *mongo.Database) error

Update ...

Types

type Dope

type Dope struct {
	// standard record values
	RecordInfo *RecordInfo `protobuf:"bytes,1,opt,name=record_info,json=recordInfo,proto3" json:"record_info,omitempty"`
	// unique identifier
	Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty" bson:"_id"`
	// super dope field 1
	Dope_1 string `protobuf:"bytes,3,opt,name=dope_1,json=dope1,proto3" json:"dope_1,omitempty"`
	// super dope field 2
	Dope_2 int32 `protobuf:"varint,4,opt,name=dope_2,json=dope2,proto3" json:"dope_2,omitempty"`
	// super dope field 3
	Dope_3 []string `protobuf:"bytes,5,rep,name=dope_3,json=dope3,proto3" json:"dope_3,omitempty"`
	// super dope field 4
	Dope_4               bool     `protobuf:"varint,6,opt,name=dope_4,json=dope4,proto3" json:"dope_4,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func Retrieve

func Retrieve(ctx context.Context, filter bson.D, db *mongo.Database) ([]*Dope, error)

Retrieve ...

func RetrieveOne

func RetrieveOne(ctx context.Context, id string, db *mongo.Database) (*Dope, error)

RetrieveOne ...

func (*Dope) Descriptor

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

func (*Dope) GetDope_1

func (m *Dope) GetDope_1() string

func (*Dope) GetDope_2

func (m *Dope) GetDope_2() int32

func (*Dope) GetDope_3

func (m *Dope) GetDope_3() []string

func (*Dope) GetDope_4

func (m *Dope) GetDope_4() bool

func (*Dope) GetId

func (m *Dope) GetId() string

func (*Dope) GetRecordInfo

func (m *Dope) GetRecordInfo() *RecordInfo

func (*Dope) ProtoMessage

func (*Dope) ProtoMessage()

func (*Dope) Reset

func (m *Dope) Reset()

func (*Dope) String

func (m *Dope) String() string

func (*Dope) XXX_DiscardUnknown

func (m *Dope) XXX_DiscardUnknown()

func (*Dope) XXX_Marshal

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

func (*Dope) XXX_Merge

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

func (*Dope) XXX_Size

func (m *Dope) XXX_Size() int

func (*Dope) XXX_Unmarshal

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

type DopeRequest

type DopeRequest struct {
	// unique identifier to help troubleshoot each request
	RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
	// username of the one making the request
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// unique identifier of the super.Dope
	Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	// dataset to process
	Payload              []*Dope  `protobuf:"bytes,4,rep,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*DopeRequest) Descriptor

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

func (*DopeRequest) GetId

func (m *DopeRequest) GetId() string

func (*DopeRequest) GetPayload

func (m *DopeRequest) GetPayload() []*Dope

func (*DopeRequest) GetRequestId

func (m *DopeRequest) GetRequestId() string

func (*DopeRequest) GetUsername

func (m *DopeRequest) GetUsername() string

func (*DopeRequest) ProtoMessage

func (*DopeRequest) ProtoMessage()

func (*DopeRequest) Reset

func (m *DopeRequest) Reset()

func (*DopeRequest) String

func (m *DopeRequest) String() string

func (*DopeRequest) XXX_DiscardUnknown

func (m *DopeRequest) XXX_DiscardUnknown()

func (*DopeRequest) XXX_Marshal

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

func (*DopeRequest) XXX_Merge

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

func (*DopeRequest) XXX_Size

func (m *DopeRequest) XXX_Size() int

func (*DopeRequest) XXX_Unmarshal

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

type DopeResponse

type DopeResponse struct {
	// unique identifier of the original incoming request to help troubleshoot
	RequestId            string   `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
	Payload              []*Dope  `protobuf:"bytes,2,rep,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*DopeResponse) Descriptor

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

func (*DopeResponse) GetPayload

func (m *DopeResponse) GetPayload() []*Dope

func (*DopeResponse) GetRequestId

func (m *DopeResponse) GetRequestId() string

func (*DopeResponse) ProtoMessage

func (*DopeResponse) ProtoMessage()

func (*DopeResponse) Reset

func (m *DopeResponse) Reset()

func (*DopeResponse) String

func (m *DopeResponse) String() string

func (*DopeResponse) XXX_DiscardUnknown

func (m *DopeResponse) XXX_DiscardUnknown()

func (*DopeResponse) XXX_Marshal

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

func (*DopeResponse) XXX_Merge

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

func (*DopeResponse) XXX_Size

func (m *DopeResponse) XXX_Size() int

func (*DopeResponse) XXX_Unmarshal

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

type DopeServer

type DopeServer struct {
	// contains filtered or unexported fields
}

func (*DopeServer) Create

func (s *DopeServer) Create(ctx context.Context, req *DopeRequest) (*Empty, error)

func (*DopeServer) Delete

func (s *DopeServer) Delete(ctx context.Context, req *DopeRequest) (*Empty, error)

func (*DopeServer) Retrieve

func (s *DopeServer) Retrieve(ctx context.Context, req *DopeRequest) (*DopeResponse, error)

func (*DopeServer) Update

func (s *DopeServer) Update(ctx context.Context, req *DopeRequest) (*DopeResponse, error)

type DopeServiceClient

type DopeServiceClient interface {
	// create new Dope item(s)
	Create(ctx context.Context, in *DopeRequest, opts ...grpc.CallOption) (*Empty, error)
	// retrieve a list of Dope items
	Retrieve(ctx context.Context, in *DopeRequest, opts ...grpc.CallOption) (*DopeResponse, error)
	// update Dope item(s)
	Update(ctx context.Context, in *DopeRequest, opts ...grpc.CallOption) (*DopeResponse, error)
	// delete Dope item(s)
	Delete(ctx context.Context, in *DopeRequest, opts ...grpc.CallOption) (*Empty, error)
}

DopeServiceClient is the client API for DopeService service.

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

func NewDopeServiceClient

func NewDopeServiceClient(cc *grpc.ClientConn) DopeServiceClient

type DopeServiceServer

type DopeServiceServer interface {
	// create new Dope item(s)
	Create(context.Context, *DopeRequest) (*Empty, error)
	// retrieve a list of Dope items
	Retrieve(context.Context, *DopeRequest) (*DopeResponse, error)
	// update Dope item(s)
	Update(context.Context, *DopeRequest) (*DopeResponse, error)
	// delete Dope item(s)
	Delete(context.Context, *DopeRequest) (*Empty, error)
}

DopeServiceServer is the server API for DopeService service.

func NewDopeServer

func NewDopeServer(cmp *config.Composition, client *mongo.Client) DopeServiceServer

type Empty

type Empty struct {
	// unique identifier of the original incoming request to help troubleshoot
	RequestId            string   `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Empty) Descriptor

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

func (*Empty) GetRequestId

func (m *Empty) GetRequestId() string

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) String

func (m *Empty) String() string

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

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

func (*Empty) XXX_Merge

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

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

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

type RecordInfo

type RecordInfo struct {
	Created              *timestamp.Timestamp `protobuf:"bytes,1,opt,name=created,proto3" json:"created,omitempty"`
	CreatedBy            string               `protobuf:"bytes,2,opt,name=created_by,json=createdBy,proto3" json:"created_by,omitempty"`
	Updated              *timestamp.Timestamp `protobuf:"bytes,3,opt,name=updated,proto3" json:"updated,omitempty"`
	UpdatedBy            string               `protobuf:"bytes,4,opt,name=updated_by,json=updatedBy,proto3" json:"updated_by,omitempty"`
	Status               RecordInfo_Status    `protobuf:"varint,5,opt,name=status,proto3,enum=super.RecordInfo_Status" json:"status,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (*RecordInfo) Descriptor

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

func (*RecordInfo) GetCreated

func (m *RecordInfo) GetCreated() *timestamp.Timestamp

func (*RecordInfo) GetCreatedBy

func (m *RecordInfo) GetCreatedBy() string

func (*RecordInfo) GetStatus

func (m *RecordInfo) GetStatus() RecordInfo_Status

func (*RecordInfo) GetUpdated

func (m *RecordInfo) GetUpdated() *timestamp.Timestamp

func (*RecordInfo) GetUpdatedBy

func (m *RecordInfo) GetUpdatedBy() string

func (*RecordInfo) ProtoMessage

func (*RecordInfo) ProtoMessage()

func (*RecordInfo) Reset

func (m *RecordInfo) Reset()

func (*RecordInfo) String

func (m *RecordInfo) String() string

func (*RecordInfo) XXX_DiscardUnknown

func (m *RecordInfo) XXX_DiscardUnknown()

func (*RecordInfo) XXX_Marshal

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

func (*RecordInfo) XXX_Merge

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

func (*RecordInfo) XXX_Size

func (m *RecordInfo) XXX_Size() int

func (*RecordInfo) XXX_Unmarshal

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

type RecordInfo_Status

type RecordInfo_Status int32
const (
	RecordInfo_draft    RecordInfo_Status = 0
	RecordInfo_active   RecordInfo_Status = 1
	RecordInfo_archived RecordInfo_Status = 2
	RecordInfo_invalid  RecordInfo_Status = 3
)

func (RecordInfo_Status) EnumDescriptor

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

func (RecordInfo_Status) String

func (x RecordInfo_Status) String() string

type UnimplementedDopeServiceServer

type UnimplementedDopeServiceServer struct {
}

UnimplementedDopeServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedDopeServiceServer) Create

func (*UnimplementedDopeServiceServer) Delete

func (*UnimplementedDopeServiceServer) Retrieve

func (*UnimplementedDopeServiceServer) Update

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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