add point to add columns to table

This commit is contained in:
Skeris 2021-03-01 19:36:52 +03:00
parent 53b8451697
commit d8b182877f
6 changed files with 319 additions and 90 deletions

@ -300,7 +300,26 @@ func (d *DAL) recordInserter(
return nil return nil
} }
type DebugNeedMutex struct {}
func (d *DAL) PutRecord(record model.Record) { func (d *DAL) PutRecord(record model.Record) {
defer func() {
val := recover()
if val != nil {
d.logger.Emit(DebugNeedMutex{})
}
}()
d.buffer = append(d.buffer, record) d.buffer = append(d.buffer, record)
return return
} }
func (d *DAL) AddColumn(ctx context.Context, name, fieldType string) error {
if _, err := d.db.ExecContext(ctx, fmt.Sprintf(`
ALTER TABLE statistics ADD COLUMN IF NOT EXISTS %s %s
`, name, fieldType)); err != nil {
return err
}
return nil
}

@ -1 +1,4 @@
package main package main
//go:generate protoc -I ./proto ./proto/trashlog.proto --go_out=plugins=grpc:./proto/generated

@ -5,8 +5,6 @@ import (
"github.com/skeris/appInit" "github.com/skeris/appInit"
) )
//go:generate protoc -I ./proto ./proto/trashlog.proto --go_out=plugins=grpc:./proto/generated
func main() { func main() {
appInit.Initialize(app.New, getEnv()) appInit.Initialize(app.New, getEnv())
} }

@ -24,6 +24,100 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Fields2Add struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Fields map[string]string `protobuf:"bytes,1,rep,name=Fields,proto3" json:"Fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *Fields2Add) Reset() {
*x = Fields2Add{}
if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Fields2Add) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Fields2Add) ProtoMessage() {}
func (x *Fields2Add) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Fields2Add.ProtoReflect.Descriptor instead.
func (*Fields2Add) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{0}
}
func (x *Fields2Add) GetFields() map[string]string {
if x != nil {
return x.Fields
}
return nil
}
type NotModified struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Columns map[string]string `protobuf:"bytes,1,rep,name=Columns,proto3" json:"Columns,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *NotModified) Reset() {
*x = NotModified{}
if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NotModified) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NotModified) ProtoMessage() {}
func (x *NotModified) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NotModified.ProtoReflect.Descriptor instead.
func (*NotModified) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{1}
}
func (x *NotModified) GetColumns() map[string]string {
if x != nil {
return x.Columns
}
return nil
}
type Dummy struct { type Dummy struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -33,7 +127,7 @@ type Dummy struct {
func (x *Dummy) Reset() { func (x *Dummy) Reset() {
*x = Dummy{} *x = Dummy{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[0] mi := &file_trashlog_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -46,7 +140,7 @@ func (x *Dummy) String() string {
func (*Dummy) ProtoMessage() {} func (*Dummy) ProtoMessage() {}
func (x *Dummy) ProtoReflect() protoreflect.Message { func (x *Dummy) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[0] mi := &file_trashlog_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -59,7 +153,7 @@ func (x *Dummy) ProtoReflect() protoreflect.Message {
// Deprecated: Use Dummy.ProtoReflect.Descriptor instead. // Deprecated: Use Dummy.ProtoReflect.Descriptor instead.
func (*Dummy) Descriptor() ([]byte, []int) { func (*Dummy) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{0} return file_trashlog_proto_rawDescGZIP(), []int{2}
} }
type Record struct { type Record struct {
@ -80,7 +174,7 @@ type Record struct {
func (x *Record) Reset() { func (x *Record) Reset() {
*x = Record{} *x = Record{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[1] mi := &file_trashlog_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -93,7 +187,7 @@ func (x *Record) String() string {
func (*Record) ProtoMessage() {} func (*Record) ProtoMessage() {}
func (x *Record) ProtoReflect() protoreflect.Message { func (x *Record) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[1] mi := &file_trashlog_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -106,7 +200,7 @@ func (x *Record) ProtoReflect() protoreflect.Message {
// Deprecated: Use Record.ProtoReflect.Descriptor instead. // Deprecated: Use Record.ProtoReflect.Descriptor instead.
func (*Record) Descriptor() ([]byte, []int) { func (*Record) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{1} return file_trashlog_proto_rawDescGZIP(), []int{3}
} }
func (x *Record) GetLevel() string { func (x *Record) GetLevel() string {
@ -180,7 +274,7 @@ type SvcData struct {
func (x *SvcData) Reset() { func (x *SvcData) Reset() {
*x = SvcData{} *x = SvcData{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[2] mi := &file_trashlog_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -193,7 +287,7 @@ func (x *SvcData) String() string {
func (*SvcData) ProtoMessage() {} func (*SvcData) ProtoMessage() {}
func (x *SvcData) ProtoReflect() protoreflect.Message { func (x *SvcData) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[2] mi := &file_trashlog_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -206,7 +300,7 @@ func (x *SvcData) ProtoReflect() protoreflect.Message {
// Deprecated: Use SvcData.ProtoReflect.Descriptor instead. // Deprecated: Use SvcData.ProtoReflect.Descriptor instead.
func (*SvcData) Descriptor() ([]byte, []int) { func (*SvcData) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{2} return file_trashlog_proto_rawDescGZIP(), []int{4}
} }
func (x *SvcData) GetBuildTime() uint64 { func (x *SvcData) GetBuildTime() uint64 {
@ -260,7 +354,7 @@ type Value struct {
func (x *Value) Reset() { func (x *Value) Reset() {
*x = Value{} *x = Value{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_trashlog_proto_msgTypes[3] mi := &file_trashlog_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -273,7 +367,7 @@ func (x *Value) String() string {
func (*Value) ProtoMessage() {} func (*Value) ProtoMessage() {}
func (x *Value) ProtoReflect() protoreflect.Message { func (x *Value) ProtoReflect() protoreflect.Message {
mi := &file_trashlog_proto_msgTypes[3] mi := &file_trashlog_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -286,7 +380,7 @@ func (x *Value) ProtoReflect() protoreflect.Message {
// Deprecated: Use Value.ProtoReflect.Descriptor instead. // Deprecated: Use Value.ProtoReflect.Descriptor instead.
func (*Value) Descriptor() ([]byte, []int) { func (*Value) Descriptor() ([]byte, []int) {
return file_trashlog_proto_rawDescGZIP(), []int{3} return file_trashlog_proto_rawDescGZIP(), []int{5}
} }
func (m *Value) GetValue() isValue_Value { func (m *Value) GetValue() isValue_Value {
@ -356,57 +450,77 @@ var File_trashlog_proto protoreflect.FileDescriptor
var file_trashlog_proto_rawDesc = []byte{ var file_trashlog_proto_rawDesc = []byte{
0x0a, 0x0e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x08, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x22, 0x07, 0x0a, 0x05, 0x44, 0x75, 0x12, 0x08, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x22, 0x81, 0x01, 0x0a, 0x0a, 0x46,
0x6d, 0x6d, 0x79, 0x22, 0xcd, 0x03, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x32, 0x41, 0x64, 0x64, 0x12, 0x38, 0x0a, 0x06, 0x46, 0x69, 0x65,
0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4c, 0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x74, 0x72, 0x61, 0x73,
0x65, 0x76, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x54, 0x53, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x32, 0x41, 0x64, 0x64, 0x2e,
0x52, 0x02, 0x54, 0x53, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x46, 0x69, 0x65,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x6c, 0x64, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74,
0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x74, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x72, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x87,
0x6b, 0x74, 0x72, 0x61, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x09, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65, 0x01, 0x0a, 0x0b, 0x4e, 0x6f, 0x74, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x3c,
0x6c, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x0a, 0x07, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x22, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x4e, 0x6f, 0x74, 0x4d, 0x6f,
0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x4b, 0x65, 0x79, 0x46, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x45, 0x6e,
0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c, 0x74, 0x72, 0x79, 0x52, 0x07, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x1a, 0x3a, 0x0a, 0x0c,
0x64, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6c, 0x6f, 0x67, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x43, 0x74, 0x78, 0x46, 0x69, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x43, 0x74, 0x78, 0x46, 0x69, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
0x65, 0x6c, 0x64, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x53, 0x76, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x07, 0x0a, 0x05, 0x44, 0x75, 0x6d, 0x6d,
0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x79, 0x22, 0xcd, 0x03, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05,
0x6f, 0x67, 0x2e, 0x53, 0x76, 0x63, 0x44, 0x61, 0x74, 0x61, 0x52, 0x09, 0x53, 0x76, 0x63, 0x46, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4c, 0x65, 0x76,
0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x4d, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65, 0x6c, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x54, 0x53, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02,
0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x54, 0x53, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x6f,
0x6c, 0x6f, 0x67, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x74, 0x72, 0x61,
0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4d, 0x0a, 0x0e, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x74,
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x72, 0x61, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x09, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65, 0x6c, 0x64,
0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65,
0x6f, 0x67, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65,
0x02, 0x38, 0x01, 0x22, 0x81, 0x01, 0x0a, 0x07, 0x53, 0x76, 0x63, 0x44, 0x61, 0x74, 0x61, 0x12, 0x6c, 0x64, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73,
0x1c, 0x0a, 0x09, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f,
0x28, 0x04, 0x52, 0x09, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x67, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c,
0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c,
0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x64, 0x73, 0x12, 0x2f, 0x0a, 0x09, 0x53, 0x76, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18,
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67,
0x12, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x46, 0x2e, 0x53, 0x76, 0x63, 0x44, 0x61, 0x74, 0x61, 0x52, 0x09, 0x53, 0x76, 0x63, 0x46, 0x69, 0x65,
0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x6c, 0x64, 0x73, 0x1a, 0x4d, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73,
0x04, 0x52, 0x04, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x68, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x12, 0x12, 0x0a, 0x03, 0x53, 0x74, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x03, 0x53, 0x74, 0x72, 0x12, 0x12, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f,
0x03, 0x48, 0x00, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x06, 0x44, 0x6f, 0x75, 0x62, 0x67, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x48, 0x00, 0x52, 0x06, 0x44, 0x6f, 0x75, 0x62, 0x38, 0x01, 0x1a, 0x4d, 0x0a, 0x0e, 0x43, 0x74, 0x78, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45,
0x6c, 0x65, 0x12, 0x14, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x48, 0x00, 0x52, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x65, 0x32, 0x3a, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x12, 0x2e, 0x0a, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67,
0x05, 0x56, 0x61, 0x6c, 0x76, 0x65, 0x12, 0x10, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
0x67, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x01, 0x22, 0x81, 0x01, 0x0a, 0x07, 0x53, 0x76, 0x63, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a,
0x6c, 0x6f, 0x67, 0x2e, 0x44, 0x75, 0x6d, 0x6d, 0x79, 0x22, 0x00, 0x28, 0x01, 0x42, 0x11, 0x5a, 0x09, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
0x0f, 0x2e, 0x3b, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x09, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x56,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x46, 0x69, 0x6c,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52,
0x04, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x68, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12,
0x0a, 0x03, 0x53, 0x74, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x53,
0x74, 0x72, 0x12, 0x12, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48,
0x00, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x06, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x48, 0x00, 0x52, 0x06, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65,
0x12, 0x14, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00,
0x52, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32,
0x73, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x12, 0x2e, 0x0a, 0x05, 0x56,
0x61, 0x6c, 0x76, 0x65, 0x12, 0x10, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x0f, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f,
0x67, 0x2e, 0x44, 0x75, 0x6d, 0x6d, 0x79, 0x22, 0x00, 0x28, 0x01, 0x12, 0x37, 0x0a, 0x06, 0x4d,
0x6f, 0x64, 0x69, 0x66, 0x79, 0x12, 0x14, 0x2e, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67,
0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x32, 0x41, 0x64, 0x64, 0x1a, 0x15, 0x2e, 0x74, 0x72,
0x61, 0x73, 0x68, 0x6c, 0x6f, 0x67, 0x2e, 0x4e, 0x6f, 0x74, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69,
0x65, 0x64, 0x22, 0x00, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x3b, 0x74, 0x72, 0x61, 0x73, 0x68, 0x6c,
0x6f, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -421,28 +535,36 @@ func file_trashlog_proto_rawDescGZIP() []byte {
return file_trashlog_proto_rawDescData return file_trashlog_proto_rawDescData
} }
var file_trashlog_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_trashlog_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_trashlog_proto_goTypes = []interface{}{ var file_trashlog_proto_goTypes = []interface{}{
(*Dummy)(nil), // 0: trashlog.Dummy (*Fields2Add)(nil), // 0: trashlog.Fields2Add
(*Record)(nil), // 1: trashlog.Record (*NotModified)(nil), // 1: trashlog.NotModified
(*SvcData)(nil), // 2: trashlog.SvcData (*Dummy)(nil), // 2: trashlog.Dummy
(*Value)(nil), // 3: trashlog.Value (*Record)(nil), // 3: trashlog.Record
nil, // 4: trashlog.Record.KeyFieldsEntry (*SvcData)(nil), // 4: trashlog.SvcData
nil, // 5: trashlog.Record.CtxFieldsEntry (*Value)(nil), // 5: trashlog.Value
nil, // 6: trashlog.Fields2Add.FieldsEntry
nil, // 7: trashlog.NotModified.ColumnsEntry
nil, // 8: trashlog.Record.KeyFieldsEntry
nil, // 9: trashlog.Record.CtxFieldsEntry
} }
var file_trashlog_proto_depIdxs = []int32{ var file_trashlog_proto_depIdxs = []int32{
4, // 0: trashlog.Record.KeyFields:type_name -> trashlog.Record.KeyFieldsEntry 6, // 0: trashlog.Fields2Add.Fields:type_name -> trashlog.Fields2Add.FieldsEntry
5, // 1: trashlog.Record.CtxFields:type_name -> trashlog.Record.CtxFieldsEntry 7, // 1: trashlog.NotModified.Columns:type_name -> trashlog.NotModified.ColumnsEntry
2, // 2: trashlog.Record.SvcFields:type_name -> trashlog.SvcData 8, // 2: trashlog.Record.KeyFields:type_name -> trashlog.Record.KeyFieldsEntry
3, // 3: trashlog.Record.KeyFieldsEntry.value:type_name -> trashlog.Value 9, // 3: trashlog.Record.CtxFields:type_name -> trashlog.Record.CtxFieldsEntry
3, // 4: trashlog.Record.CtxFieldsEntry.value:type_name -> trashlog.Value 4, // 4: trashlog.Record.SvcFields:type_name -> trashlog.SvcData
1, // 5: trashlog.Trashlog.Valve:input_type -> trashlog.Record 5, // 5: trashlog.Record.KeyFieldsEntry.value:type_name -> trashlog.Value
0, // 6: trashlog.Trashlog.Valve:output_type -> trashlog.Dummy 5, // 6: trashlog.Record.CtxFieldsEntry.value:type_name -> trashlog.Value
6, // [6:7] is the sub-list for method output_type 3, // 7: trashlog.Trashlog.Valve:input_type -> trashlog.Record
5, // [5:6] is the sub-list for method input_type 0, // 8: trashlog.Trashlog.Modify:input_type -> trashlog.Fields2Add
5, // [5:5] is the sub-list for extension type_name 2, // 9: trashlog.Trashlog.Valve:output_type -> trashlog.Dummy
5, // [5:5] is the sub-list for extension extendee 1, // 10: trashlog.Trashlog.Modify:output_type -> trashlog.NotModified
0, // [0:5] is the sub-list for field type_name 9, // [9:11] is the sub-list for method output_type
7, // [7:9] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
} }
func init() { file_trashlog_proto_init() } func init() { file_trashlog_proto_init() }
@ -452,7 +574,7 @@ func file_trashlog_proto_init() {
} }
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_trashlog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_trashlog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Dummy); i { switch v := v.(*Fields2Add); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -464,7 +586,7 @@ func file_trashlog_proto_init() {
} }
} }
file_trashlog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_trashlog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Record); i { switch v := v.(*NotModified); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -476,7 +598,7 @@ func file_trashlog_proto_init() {
} }
} }
file_trashlog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_trashlog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SvcData); i { switch v := v.(*Dummy); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -488,6 +610,30 @@ func file_trashlog_proto_init() {
} }
} }
file_trashlog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_trashlog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Record); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_trashlog_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SvcData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_trashlog_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Value); i { switch v := v.(*Value); i {
case 0: case 0:
return &v.state return &v.state
@ -500,7 +646,7 @@ func file_trashlog_proto_init() {
} }
} }
} }
file_trashlog_proto_msgTypes[3].OneofWrappers = []interface{}{ file_trashlog_proto_msgTypes[5].OneofWrappers = []interface{}{
(*Value_Str)(nil), (*Value_Str)(nil),
(*Value_Num)(nil), (*Value_Num)(nil),
(*Value_Double)(nil), (*Value_Double)(nil),
@ -512,7 +658,7 @@ func file_trashlog_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_trashlog_proto_rawDesc, RawDescriptor: file_trashlog_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 10,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
@ -539,6 +685,7 @@ const _ = grpc.SupportPackageIsVersion6
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type TrashlogClient interface { type TrashlogClient interface {
Valve(ctx context.Context, opts ...grpc.CallOption) (Trashlog_ValveClient, error) Valve(ctx context.Context, opts ...grpc.CallOption) (Trashlog_ValveClient, error)
Modify(ctx context.Context, in *Fields2Add, opts ...grpc.CallOption) (*NotModified, error)
} }
type trashlogClient struct { type trashlogClient struct {
@ -583,9 +730,19 @@ func (x *trashlogValveClient) CloseAndRecv() (*Dummy, error) {
return m, nil return m, nil
} }
func (c *trashlogClient) Modify(ctx context.Context, in *Fields2Add, opts ...grpc.CallOption) (*NotModified, error) {
out := new(NotModified)
err := c.cc.Invoke(ctx, "/trashlog.Trashlog/Modify", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TrashlogServer is the server API for Trashlog service. // TrashlogServer is the server API for Trashlog service.
type TrashlogServer interface { type TrashlogServer interface {
Valve(Trashlog_ValveServer) error Valve(Trashlog_ValveServer) error
Modify(context.Context, *Fields2Add) (*NotModified, error)
} }
// UnimplementedTrashlogServer can be embedded to have forward compatible implementations. // UnimplementedTrashlogServer can be embedded to have forward compatible implementations.
@ -595,6 +752,9 @@ type UnimplementedTrashlogServer struct {
func (*UnimplementedTrashlogServer) Valve(Trashlog_ValveServer) error { func (*UnimplementedTrashlogServer) Valve(Trashlog_ValveServer) error {
return status.Errorf(codes.Unimplemented, "method Valve not implemented") return status.Errorf(codes.Unimplemented, "method Valve not implemented")
} }
func (*UnimplementedTrashlogServer) Modify(context.Context, *Fields2Add) (*NotModified, error) {
return nil, status.Errorf(codes.Unimplemented, "method Modify not implemented")
}
func RegisterTrashlogServer(s *grpc.Server, srv TrashlogServer) { func RegisterTrashlogServer(s *grpc.Server, srv TrashlogServer) {
s.RegisterService(&_Trashlog_serviceDesc, srv) s.RegisterService(&_Trashlog_serviceDesc, srv)
@ -626,10 +786,33 @@ func (x *trashlogValveServer) Recv() (*Record, error) {
return m, nil return m, nil
} }
func _Trashlog_Modify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Fields2Add)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TrashlogServer).Modify(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/trashlog.Trashlog/Modify",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TrashlogServer).Modify(ctx, req.(*Fields2Add))
}
return interceptor(ctx, in, info, handler)
}
var _Trashlog_serviceDesc = grpc.ServiceDesc{ var _Trashlog_serviceDesc = grpc.ServiceDesc{
ServiceName: "trashlog.Trashlog", ServiceName: "trashlog.Trashlog",
HandlerType: (*TrashlogServer)(nil), HandlerType: (*TrashlogServer)(nil),
Methods: []grpc.MethodDesc{}, Methods: []grpc.MethodDesc{
{
MethodName: "Modify",
Handler: _Trashlog_Modify_Handler,
},
},
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{
{ {
StreamName: "Valve", StreamName: "Valve",

@ -6,6 +6,15 @@ package trashlog;
service Trashlog{ service Trashlog{
rpc Valve(stream Record) returns (Dummy) {} rpc Valve(stream Record) returns (Dummy) {}
rpc Modify(Fields2Add) returns (NotModified) {}
}
message Fields2Add{
map<string, string> Fields = 1;
}
message NotModified{
map<string, string> Columns = 1;
} }
message Dummy{} message Dummy{}

@ -1,6 +1,7 @@
package sink package sink
import ( import (
"context"
"github.com/BlackBroker/trashlog/dal/clickhouse" "github.com/BlackBroker/trashlog/dal/clickhouse"
"github.com/BlackBroker/trashlog/model" "github.com/BlackBroker/trashlog/model"
trashlogProto "github.com/BlackBroker/trashlog/proto/generated" trashlogProto "github.com/BlackBroker/trashlog/proto/generated"
@ -19,6 +20,22 @@ func New(log hlog.Logger, store *clickhouse.DAL) *Sink {
} }
} }
func (s *Sink) Modify(
ctx context.Context,
fields *trashlogProto.Fields2Add,
) (*trashlogProto.NotModified, error) {
var result = trashlogProto.NotModified{}
for name, fieldType := range fields.Fields {
if err := s.store.AddColumn(ctx, name, fieldType); err != nil {
result.Columns[name] = err.Error()
}
}
return &result, nil
}
func (s *Sink) Valve(stream trashlogProto.Trashlog_ValveServer) error { func (s *Sink) Valve(stream trashlogProto.Trashlog_ValveServer) error {
ctxChan := stream.Context() ctxChan := stream.Context()
dataChan := make(chan *trashlogProto.Record) dataChan := make(chan *trashlogProto.Record)