Skip to content
Snippets Groups Projects
Commit 15a713cd authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-2665-LogsAddSearchScore' into 'master'

Обновление API логирования, релевантность результатов поиска

See merge request perxis/perxis-go!270
parents 83c68733 97077fbc
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ type Entry struct {
CallerID *id.ObjectId `json:"caller_id,omitempty" bson:"caller_id,omitempty" mapstructure:"caller_id,omitempty"`
Attr interface{} `json:"attr,omitempty" bson:"attr,omitempty" mapstructure:"attr,omitempty"`
Tags []string `json:"tags,omitempty" bson:"tags,omitempty" mapstructure:"tags,omitempty"`
SearchScore float64 `json:"searchScore,omitempty" bson:"search_score,omitempty"`
}
//func convertInterfaceToAny(v interface{}) (*any.Any, error) {
......@@ -61,6 +62,7 @@ func EntryToPB(entry *Entry) *pb.LogEntry {
Event: entry.Event,
Attr: nil, //implement
Tags: entry.Tags,
SearchScore: entry.SearchScore,
}
if entry.ObjectID != nil {
logEntry.ObjectId = entry.ObjectID.String()
......@@ -81,6 +83,7 @@ func EntryFromPB(request *pb.LogEntry) *Entry {
Category: request.Category,
Component: request.Component,
Event: request.Event,
SearchScore: request.SearchScore,
}
if request.ObjectId != "" {
......
......@@ -5,7 +5,7 @@ package mocks
import (
context "context"
log2 "git.perx.ru/perxis/perxis-go/logs"
logs "git.perx.ru/perxis/perxis-go/logs"
mock "github.com/stretchr/testify/mock"
options "git.perx.ru/perxis/perxis-go/pkg/options"
......@@ -17,7 +17,7 @@ type Service struct {
}
// Delete provides a mock function with given fields: ctx, filter
func (_m *Service) Delete(ctx context.Context, filter *log2.Filter) error {
func (_m *Service) Delete(ctx context.Context, filter *logs.Filter) error {
ret := _m.Called(ctx, filter)
if len(ret) == 0 {
......@@ -25,7 +25,7 @@ func (_m *Service) Delete(ctx context.Context, filter *log2.Filter) error {
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter) error); ok {
r0 = rf(ctx, filter)
} else {
r0 = ret.Error(0)
......@@ -35,27 +35,27 @@ func (_m *Service) Delete(ctx context.Context, filter *log2.Filter) error {
}
// Find provides a mock function with given fields: ctx, filter, _a2
func (_m *Service) Find(ctx context.Context, filter *log2.Filter, _a2 *options.FindOptions) (*log2.FindResult, error) {
func (_m *Service) Find(ctx context.Context, filter *logs.Filter, _a2 *options.FindOptions) (*logs.FindResult, error) {
ret := _m.Called(ctx, filter, _a2)
if len(ret) == 0 {
panic("no return value specified for Find")
}
var r0 *log2.FindResult
var r0 *logs.FindResult
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter, *options.FindOptions) (*log2.FindResult, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter, *options.FindOptions) (*logs.FindResult, error)); ok {
return rf(ctx, filter, _a2)
}
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter, *options.FindOptions) *log2.FindResult); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter, *options.FindOptions) *logs.FindResult); ok {
r0 = rf(ctx, filter, _a2)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*log2.FindResult)
r0 = ret.Get(0).(*logs.FindResult)
}
}
if rf, ok := ret.Get(1).(func(context.Context, *log2.Filter, *options.FindOptions) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *logs.Filter, *options.FindOptions) error); ok {
r1 = rf(ctx, filter, _a2)
} else {
r1 = ret.Error(1)
......@@ -65,7 +65,7 @@ func (_m *Service) Find(ctx context.Context, filter *log2.Filter, _a2 *options.F
}
// Log provides a mock function with given fields: ctx, entries
func (_m *Service) Log(ctx context.Context, entries []*log2.Entry) error {
func (_m *Service) Log(ctx context.Context, entries []*logs.Entry) error {
ret := _m.Called(ctx, entries)
if len(ret) == 0 {
......@@ -73,7 +73,7 @@ func (_m *Service) Log(ctx context.Context, entries []*log2.Entry) error {
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, []*log2.Entry) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, []*logs.Entry) error); ok {
r0 = rf(ctx, entries)
} else {
r0 = ret.Error(0)
......
......@@ -5,7 +5,7 @@ package mocks
import (
context "context"
log2 "git.perx.ru/perxis/perxis-go/logs"
logs "git.perx.ru/perxis/perxis-go/logs"
mock "github.com/stretchr/testify/mock"
options "git.perx.ru/perxis/perxis-go/pkg/options"
......@@ -17,7 +17,7 @@ type Storage struct {
}
// Delete provides a mock function with given fields: ctx, filter
func (_m *Storage) Delete(ctx context.Context, filter *log2.Filter) error {
func (_m *Storage) Delete(ctx context.Context, filter *logs.Filter) error {
ret := _m.Called(ctx, filter)
if len(ret) == 0 {
......@@ -25,7 +25,7 @@ func (_m *Storage) Delete(ctx context.Context, filter *log2.Filter) error {
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter) error); ok {
r0 = rf(ctx, filter)
} else {
r0 = ret.Error(0)
......@@ -35,34 +35,34 @@ func (_m *Storage) Delete(ctx context.Context, filter *log2.Filter) error {
}
// Find provides a mock function with given fields: ctx, filter, _a2
func (_m *Storage) Find(ctx context.Context, filter *log2.Filter, _a2 *options.FindOptions) ([]*log2.Entry, int, error) {
func (_m *Storage) Find(ctx context.Context, filter *logs.Filter, _a2 *options.FindOptions) ([]*logs.Entry, int, error) {
ret := _m.Called(ctx, filter, _a2)
if len(ret) == 0 {
panic("no return value specified for Find")
}
var r0 []*log2.Entry
var r0 []*logs.Entry
var r1 int
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter, *options.FindOptions) ([]*log2.Entry, int, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter, *options.FindOptions) ([]*logs.Entry, int, error)); ok {
return rf(ctx, filter, _a2)
}
if rf, ok := ret.Get(0).(func(context.Context, *log2.Filter, *options.FindOptions) []*log2.Entry); ok {
if rf, ok := ret.Get(0).(func(context.Context, *logs.Filter, *options.FindOptions) []*logs.Entry); ok {
r0 = rf(ctx, filter, _a2)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*log2.Entry)
r0 = ret.Get(0).([]*logs.Entry)
}
}
if rf, ok := ret.Get(1).(func(context.Context, *log2.Filter, *options.FindOptions) int); ok {
if rf, ok := ret.Get(1).(func(context.Context, *logs.Filter, *options.FindOptions) int); ok {
r1 = rf(ctx, filter, _a2)
} else {
r1 = ret.Get(1).(int)
}
if rf, ok := ret.Get(2).(func(context.Context, *log2.Filter, *options.FindOptions) error); ok {
if rf, ok := ret.Get(2).(func(context.Context, *logs.Filter, *options.FindOptions) error); ok {
r2 = rf(ctx, filter, _a2)
} else {
r2 = ret.Error(2)
......@@ -90,7 +90,7 @@ func (_m *Storage) Init(ctx context.Context) error {
}
// Log provides a mock function with given fields: ctx, entry
func (_m *Storage) Log(ctx context.Context, entry []*log2.Entry) error {
func (_m *Storage) Log(ctx context.Context, entry []*logs.Entry) error {
ret := _m.Called(ctx, entry)
if len(ret) == 0 {
......@@ -98,7 +98,7 @@ func (_m *Storage) Log(ctx context.Context, entry []*log2.Entry) error {
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, []*log2.Entry) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, []*logs.Entry) error); ok {
r0 = rf(ctx, entry)
} else {
r0 = ret.Error(0)
......
......@@ -146,6 +146,8 @@ type LogEntry struct {
Attr *anypb.Any `protobuf:"bytes,10,opt,name=attr,proto3" json:"attr,omitempty"`
// tags содержит теги связанные с событием, на усмотрение сервиса
Tags []string `protobuf:"bytes,11,rep,name=tags,proto3" json:"tags,omitempty"`
// релевантность элемента при полнотекстовом поиске
SearchScore float64 `protobuf:"fixed64,12,opt,name=search_score,json=searchScore,proto3" json:"search_score,omitempty"`
}
func (x *LogEntry) Reset() {
......@@ -257,6 +259,13 @@ func (x *LogEntry) GetTags() []string {
return nil
}
func (x *LogEntry) GetSearchScore() float64 {
if x != nil {
return x.SearchScore
}
return 0
}
var File_logs_log_proto protoreflect.FileDescriptor
var file_logs_log_proto_rawDesc = []byte{
......@@ -266,7 +275,7 @@ var file_logs_log_proto_rawDesc = []byte{
0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x12, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdc, 0x02, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x45, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xff, 0x02, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
......@@ -288,15 +297,17 @@ var file_logs_log_proto_rawDesc = []byte{
0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x61, 0x74, 0x74,
0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52,
0x04, 0x74, 0x61, 0x67, 0x73, 0x2a, 0x45, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x57,
0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f,
0x52, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54, 0x49, 0x43, 0x41, 0x4c, 0x10,
0x03, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x04, 0x42, 0x2e, 0x5a, 0x2c,
0x67, 0x69, 0x74, 0x2e, 0x70, 0x65, 0x72, 0x78, 0x2e, 0x72, 0x75, 0x2f, 0x70, 0x65, 0x72, 0x78,
0x69, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x78, 0x69, 0x73, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x6c, 0x6f, 0x67, 0x73, 0x3b, 0x6c, 0x6f, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f,
0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x73, 0x65, 0x61,
0x72, 0x63, 0x68, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x2a, 0x45, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c,
0x65, 0x76, 0x65, 0x6c, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x00, 0x12, 0x0b,
0x0a, 0x07, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x45,
0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54, 0x49, 0x43,
0x41, 0x4c, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x04, 0x42,
0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x70, 0x65, 0x72, 0x78, 0x2e, 0x72, 0x75, 0x2f, 0x70,
0x65, 0x72, 0x78, 0x69, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x78, 0x69, 0x73, 0x2d, 0x67, 0x6f, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x6f, 0x67, 0x73, 0x3b, 0x6c, 0x6f, 0x67, 0x73, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment