pull/14/head
Andrey Ivanov 2020-09-27 13:27:33 -04:00 committed by tiburon
parent 83495e1e79
commit 34a017b088
5 changed files with 320 additions and 2 deletions

View File

@ -13,4 +13,6 @@ lint: install-lint-deps
install-lint-deps:
(which golangci-lint > /dev/null) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.30.0
generate:
protoc --go_out=grpc:internal grpc/calendar.proto
.PHONY: build run test lint

View File

@ -0,0 +1,316 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: grpc/calendar.proto
package event
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
duration "github.com/golang/protobuf/ptypes/duration"
_ "github.com/golang/protobuf/ptypes/empty"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
math "math"
)
// 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.ProtoPackageIsVersion3 // please upgrade the proto package
type Event struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
Date *timestamp.Timestamp `protobuf:"bytes,3,opt,name=date,proto3" json:"date,omitempty"`
Latency *duration.Duration `protobuf:"bytes,4,opt,name=latency,proto3" json:"latency,omitempty"`
Note string `protobuf:"bytes,5,opt,name=note,proto3" json:"note,omitempty"`
UserID string `protobuf:"bytes,6,opt,name=UserID,proto3" json:"UserID,omitempty"`
NotyfyTime *duration.Duration `protobuf:"bytes,7,opt,name=notyfyTime,proto3" json:"notyfyTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Event) Reset() { *m = Event{} }
func (m *Event) String() string { return proto.CompactTextString(m) }
func (*Event) ProtoMessage() {}
func (*Event) Descriptor() ([]byte, []int) {
return fileDescriptor_b5d285f4b6d41dfd, []int{0}
}
func (m *Event) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Event.Unmarshal(m, b)
}
func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Event.Marshal(b, m, deterministic)
}
func (m *Event) XXX_Merge(src proto.Message) {
xxx_messageInfo_Event.Merge(m, src)
}
func (m *Event) XXX_Size() int {
return xxx_messageInfo_Event.Size(m)
}
func (m *Event) XXX_DiscardUnknown() {
xxx_messageInfo_Event.DiscardUnknown(m)
}
var xxx_messageInfo_Event proto.InternalMessageInfo
func (m *Event) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *Event) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (m *Event) GetDate() *timestamp.Timestamp {
if m != nil {
return m.Date
}
return nil
}
func (m *Event) GetLatency() *duration.Duration {
if m != nil {
return m.Latency
}
return nil
}
func (m *Event) GetNote() string {
if m != nil {
return m.Note
}
return ""
}
func (m *Event) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *Event) GetNotyfyTime() *duration.Duration {
if m != nil {
return m.NotyfyTime
}
return nil
}
type EventList struct {
Events []*Event `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventList) Reset() { *m = EventList{} }
func (m *EventList) String() string { return proto.CompactTextString(m) }
func (*EventList) ProtoMessage() {}
func (*EventList) Descriptor() ([]byte, []int) {
return fileDescriptor_b5d285f4b6d41dfd, []int{1}
}
func (m *EventList) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventList.Unmarshal(m, b)
}
func (m *EventList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventList.Marshal(b, m, deterministic)
}
func (m *EventList) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventList.Merge(m, src)
}
func (m *EventList) XXX_Size() int {
return xxx_messageInfo_EventList.Size(m)
}
func (m *EventList) XXX_DiscardUnknown() {
xxx_messageInfo_EventList.DiscardUnknown(m)
}
var xxx_messageInfo_EventList proto.InternalMessageInfo
func (m *EventList) GetEvents() []*Event {
if m != nil {
return m.Events
}
return nil
}
type EventID struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventID) Reset() { *m = EventID{} }
func (m *EventID) String() string { return proto.CompactTextString(m) }
func (*EventID) ProtoMessage() {}
func (*EventID) Descriptor() ([]byte, []int) {
return fileDescriptor_b5d285f4b6d41dfd, []int{2}
}
func (m *EventID) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventID.Unmarshal(m, b)
}
func (m *EventID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventID.Marshal(b, m, deterministic)
}
func (m *EventID) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventID.Merge(m, src)
}
func (m *EventID) XXX_Size() int {
return xxx_messageInfo_EventID.Size(m)
}
func (m *EventID) XXX_DiscardUnknown() {
xxx_messageInfo_EventID.DiscardUnknown(m)
}
var xxx_messageInfo_EventID proto.InternalMessageInfo
func (m *EventID) GetID() string {
if m != nil {
return m.ID
}
return ""
}
type EventWithID struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Event *Event `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventWithID) Reset() { *m = EventWithID{} }
func (m *EventWithID) String() string { return proto.CompactTextString(m) }
func (*EventWithID) ProtoMessage() {}
func (*EventWithID) Descriptor() ([]byte, []int) {
return fileDescriptor_b5d285f4b6d41dfd, []int{3}
}
func (m *EventWithID) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventWithID.Unmarshal(m, b)
}
func (m *EventWithID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventWithID.Marshal(b, m, deterministic)
}
func (m *EventWithID) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventWithID.Merge(m, src)
}
func (m *EventWithID) XXX_Size() int {
return xxx_messageInfo_EventWithID.Size(m)
}
func (m *EventWithID) XXX_DiscardUnknown() {
xxx_messageInfo_EventWithID.DiscardUnknown(m)
}
var xxx_messageInfo_EventWithID proto.InternalMessageInfo
func (m *EventWithID) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *EventWithID) GetEvent() *Event {
if m != nil {
return m.Event
}
return nil
}
type Date struct {
Date *timestamp.Timestamp `protobuf:"bytes,1,opt,name=date,proto3" json:"date,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Date) Reset() { *m = Date{} }
func (m *Date) String() string { return proto.CompactTextString(m) }
func (*Date) ProtoMessage() {}
func (*Date) Descriptor() ([]byte, []int) {
return fileDescriptor_b5d285f4b6d41dfd, []int{4}
}
func (m *Date) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Date.Unmarshal(m, b)
}
func (m *Date) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Date.Marshal(b, m, deterministic)
}
func (m *Date) XXX_Merge(src proto.Message) {
xxx_messageInfo_Date.Merge(m, src)
}
func (m *Date) XXX_Size() int {
return xxx_messageInfo_Date.Size(m)
}
func (m *Date) XXX_DiscardUnknown() {
xxx_messageInfo_Date.DiscardUnknown(m)
}
var xxx_messageInfo_Date proto.InternalMessageInfo
func (m *Date) GetDate() *timestamp.Timestamp {
if m != nil {
return m.Date
}
return nil
}
func init() {
proto.RegisterType((*Event)(nil), "event.event")
proto.RegisterType((*EventList)(nil), "event.eventList")
proto.RegisterType((*EventID)(nil), "event.eventID")
proto.RegisterType((*EventWithID)(nil), "event.eventWithID")
proto.RegisterType((*Date)(nil), "event.date")
}
func init() { proto.RegisterFile("grpc/calendar.proto", fileDescriptor_b5d285f4b6d41dfd) }
var fileDescriptor_b5d285f4b6d41dfd = []byte{
// 429 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xdf, 0x8b, 0xd3, 0x40,
0x10, 0xc7, 0x49, 0x7f, 0x24, 0x76, 0x22, 0x87, 0x8c, 0x72, 0xec, 0x45, 0xd0, 0x12, 0x44, 0xaa,
0x07, 0xa9, 0xf6, 0x44, 0xf0, 0xd1, 0xeb, 0x8a, 0x04, 0x14, 0x24, 0x78, 0x1c, 0xf8, 0x96, 0x6b,
0xe7, 0x7a, 0xc1, 0x34, 0x1b, 0xd2, 0x39, 0x21, 0x6f, 0xfe, 0xdb, 0xbe, 0x49, 0x66, 0x53, 0xa9,
0xa9, 0x5a, 0x5f, 0xc2, 0xce, 0x7e, 0x3f, 0x3b, 0xdf, 0x9d, 0x6f, 0x16, 0xee, 0xaf, 0xaa, 0x72,
0x31, 0x5d, 0xa4, 0x39, 0x15, 0xcb, 0xb4, 0x8a, 0xca, 0xca, 0xb0, 0xc1, 0x21, 0x7d, 0xa3, 0x82,
0x83, 0xc7, 0x2b, 0x63, 0x56, 0x39, 0x4d, 0x65, 0xf3, 0xea, 0xf6, 0x7a, 0xca, 0xd9, 0x9a, 0x36,
0x9c, 0xae, 0x4b, 0xcb, 0x05, 0x8f, 0xba, 0xc0, 0xf2, 0xb6, 0x4a, 0x39, 0x33, 0x45, 0xab, 0x3f,
0xec, 0xea, 0xb4, 0x2e, 0xb9, 0xb6, 0x62, 0xf8, 0xc3, 0x01, 0xeb, 0x83, 0x47, 0xd0, 0x8b, 0xb5,
0x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0xdc, 0x55, 0xec, 0x04, 0xc1, 0xf1,
0x9e, 0xef, 0xbb, 0xe6, 0xe1, 0xe0, 0x0b, 0x70, 0x35, 0xe5, 0xc4, 0x84, 0x9d, 0x7e, 0xff, 0x38,
0x31, 0x90, 0x8c, 0xff, 0xa2, 0x07, 0xf7, 0x76, 0xfb, 0x08, 0x79, 0x0a, 0xde, 0x7b, 0xe2, 0xf3,
0xba, 0x09, 0xb2, 0x63, 0xb2, 0x0f, 0x3f, 0x83, 0x3b, 0x02, 0xeb, 0xb4, 0x46, 0xbf, 0x55, 0x9b,
0xa9, 0xfe, 0x80, 0x3e, 0x87, 0x91, 0xa0, 0x97, 0x44, 0x5f, 0x0f, 0xb1, 0xa7, 0x00, 0xc2, 0x7e,
0x34, 0x05, 0xdf, 0x1c, 0x80, 0xcf, 0xbd, 0x2f, 0xf6, 0x1f, 0x5e, 0xb9, 0x32, 0xdb, 0xd9, 0xcf,
0x00, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xa8, 0x5f, 0x40, 0xd3, 0x03, 0x00, 0x00,
}

View File

@ -22,7 +22,7 @@ type Logger struct {
Logger amitralog.Logger
}
var validLevel = map[string]bool{"debug": true, "info":true, "warn": true, "error": true, "fatal": true}
var validLevel = map[string]bool{"debug": true, "info": true, "warn": true, "error": true, "fatal": true}
func New(conf config.Config) (Interface, error) {
if conf.Logger.File == "" || !validLevel[strings.ToLower(conf.Logger.Level)] {

View File

@ -83,7 +83,7 @@ func (s *Storage) Delete(id event.ID) error {
func (s *Storage) List() (map[event.ID]event.Event, error) {
res := make(map[event.ID]event.Event)
results, err := s.db.Query( `SELECT (id,title,date,latency,note,userID,notifyTime) from events ORDER BY id`)
results, err := s.db.Query(`SELECT (id,title,date,latency,note,userID,notifyTime) from events ORDER BY id`)
if err != nil {
return nil, err
}