From 08b31a2f0fe81f90e2315251f74dedf40260710e Mon Sep 17 00:00:00 2001 From: suifri Date: Mon, 27 Jul 2026 13:57:00 +0300 Subject: [PATCH] [WTEL-7767]feature(trigger): add call_recording to enum --- app/event_trigger.go | 16 ++-- gen/engine/trigger.pb.go | 154 ++++++++++++++++++++------------------- model/cc_trigger.go | 1 - utils/lru.go | 32 ++++---- utils/network.go | 2 +- 5 files changed, 107 insertions(+), 98 deletions(-) diff --git a/app/event_trigger.go b/app/event_trigger.go index 400b30fe..f4a75026 100644 --- a/app/event_trigger.go +++ b/app/event_trigger.go @@ -4,16 +4,17 @@ import ( "context" "encoding/json" "fmt" + "strconv" + "strings" + "sync/atomic" + "time" + amqp "github.com/rabbitmq/amqp091-go" "github.com/webitel/engine/app/flow" "github.com/webitel/engine/model" "github.com/webitel/engine/store" "github.com/webitel/engine/utils" "github.com/webitel/wlog" - "strconv" - "strings" - "sync/atomic" - "time" ) const ( @@ -236,10 +237,10 @@ func (ct *TriggerEventMQ) processedMessages(messages <-chan amqp.Delivery) { rs.variables["action"] = event job, err := ct.store.Trigger().CreateJob(ctx, rs.domainId, rs.triggerId, rs.variables) if err != nil { - ct.log.Error(fmt.Sprintf("could not create job: %v: %s", rs, err.Error())) + ct.log.Error("creating trigger job", wlog.Any("request", rs), wlog.Err(err)) return } - ct.log.Info(fmt.Sprintf("started trigger \"%s\" job_id : %d", rs.name, job.Id)) + ct.log.Info("started trigger", wlog.String("name", rs.name), wlog.Int64("job_id", job.Id)) } } } @@ -317,7 +318,8 @@ func (ct *TriggerEventMQ) initQueue() error { true, false, false, - false, amqp.Table{"x-queue-type": "quorum"}, + false, + amqp.Table{"x-queue-type": "quorum"}, ) if err != nil { return fmt.Errorf("could not create queue %s: %w", ct.config.Queue, err) diff --git a/gen/engine/trigger.pb.go b/gen/engine/trigger.pb.go index f5d6177c..36a332a5 100644 --- a/gen/engine/trigger.pb.go +++ b/gen/engine/trigger.pb.go @@ -80,6 +80,7 @@ const ( TriggerObjectType_case_comments TriggerObjectType = 3 TriggerObjectType_case_links TriggerObjectType = 4 TriggerObjectType_related_cases TriggerObjectType = 5 + TriggerObjectType_call TriggerObjectType = 6 ) // Enum value maps for TriggerObjectType. @@ -91,6 +92,7 @@ var ( 3: "case_comments", 4: "case_links", 5: "related_cases", + 6: "call", } TriggerObjectType_value = map[string]int32{ "empty_trigger_object": 0, @@ -99,6 +101,7 @@ var ( "case_comments": 3, "case_links": 4, "related_cases": 5, + "call": 6, } ) @@ -137,6 +140,7 @@ const ( TriggerEventType_update TriggerEventType = 2 TriggerEventType_remove TriggerEventType = 3 TriggerEventType_resolution_time TriggerEventType = 4 + TriggerEventType_record_call TriggerEventType = 5 ) // Enum value maps for TriggerEventType. @@ -147,6 +151,7 @@ var ( 2: "update", 3: "remove", 4: "resolution_time", + 5: "record_call", } TriggerEventType_value = map[string]int32{ "empty_trigger_event": 0, @@ -154,6 +159,7 @@ var ( "update": 2, "remove": 3, "resolution_time": 4, + "record_call": 5, } ) @@ -1364,11 +1370,11 @@ var File_trigger_proto protoreflect.FileDescriptor var file_trigger_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x1a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc4, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, @@ -1588,75 +1594,77 @@ var file_trigger_proto_rawDesc = []byte{ 0x12, 0x18, 0x0a, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x02, 0x2a, - 0x7e, 0x0a, 0x11, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, 0x72, - 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x00, 0x12, 0x09, - 0x0a, 0x05, 0x63, 0x61, 0x73, 0x65, 0x73, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x63, 0x61, 0x73, - 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x63, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, - 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x10, 0x05, 0x2a, - 0x64, 0x0a, 0x10, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, 0x72, 0x69, - 0x67, 0x67, 0x65, 0x72, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x03, - 0x12, 0x13, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x10, 0x04, 0x2a, 0x3c, 0x0a, 0x0f, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, - 0x4a, 0x6f, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x69, 0x64, 0x6c, 0x65, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x64, 0x6f, 0x6e, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x10, 0x03, 0x32, 0xf6, 0x05, 0x0a, 0x0e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x3a, 0x01, - 0x2a, 0x22, 0x08, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x0d, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, + 0x88, 0x01, 0x0a, 0x11, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, + 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x00, 0x12, + 0x09, 0x0a, 0x05, 0x63, 0x61, 0x73, 0x65, 0x73, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x63, 0x61, + 0x73, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x63, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x10, 0x03, 0x12, 0x0e, 0x0a, + 0x0a, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x10, 0x04, 0x12, 0x11, 0x0a, + 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x10, 0x05, + 0x12, 0x08, 0x0a, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x10, 0x06, 0x2a, 0x75, 0x0a, 0x10, 0x54, 0x72, + 0x69, 0x67, 0x67, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x17, + 0x0a, 0x13, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x5f, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x02, 0x12, + 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x72, + 0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x10, 0x04, + 0x12, 0x0f, 0x0a, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x10, + 0x05, 0x2a, 0x3c, 0x0a, 0x0f, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x69, 0x64, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x0a, + 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x64, 0x6f, + 0x6e, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x03, 0x32, + 0xf6, 0x05, 0x0a, 0x0e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, + 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, + 0x65, 0x72, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x3a, 0x01, 0x2a, 0x22, 0x08, 0x2f, + 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, + 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x10, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x51, 0x0a, + 0x0b, 0x52, 0x65, 0x61, 0x64, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x65, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, + 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0f, 0x12, 0x0d, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, + 0x12, 0x58, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, + 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, + 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x1a, 0x0d, 0x2f, 0x74, 0x72, + 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x56, 0x0a, 0x0c, 0x50, 0x61, + 0x74, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, + 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, + 0x3a, 0x01, 0x2a, 0x32, 0x0d, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, + 0x64, 0x7d, 0x12, 0x55, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, + 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, + 0x65, 0x72, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x2a, 0x0d, 0x2f, 0x74, 0x72, 0x69, + 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x6d, 0x0a, 0x10, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x12, 0x1f, 0x2e, + 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, + 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, + 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, + 0x6f, 0x62, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x01, 0x2a, 0x22, 0x19, 0x2f, + 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6a, 0x6f, 0x62, 0x12, 0x6e, 0x0a, 0x10, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x12, 0x1f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, - 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x6e, 0x67, - 0x69, 0x6e, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, - 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, - 0x72, 0x12, 0x51, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, - 0x12, 0x1a, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x54, 0x72, - 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, - 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x15, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, - 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x58, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, - 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, - 0x67, 0x67, 0x65, 0x72, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x1a, - 0x0d, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x56, - 0x0a, 0x0c, 0x50, 0x61, 0x74, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1b, - 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x54, 0x72, 0x69, - 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, - 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x18, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x32, 0x0d, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, - 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x55, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x2a, 0x0d, - 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x6d, 0x0a, - 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, - 0x62, 0x12, 0x1f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x54, 0x72, 0x69, 0x67, - 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x01, - 0x2a, 0x22, 0x19, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x74, 0x72, 0x69, - 0x67, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6a, 0x6f, 0x62, 0x12, 0x6e, 0x0a, 0x10, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, - 0x12, 0x1f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x1b, 0x12, 0x19, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x74, 0x72, 0x69, - 0x67, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6a, 0x6f, 0x62, 0x42, 0x22, 0x5a, 0x20, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x65, 0x62, 0x69, 0x74, - 0x65, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, + 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, 0x2f, + 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x7b, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6a, 0x6f, 0x62, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x65, 0x62, 0x69, 0x74, 0x65, 0x6c, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/model/cc_trigger.go b/model/cc_trigger.go index 86f82a97..7d972ffc 100644 --- a/model/cc_trigger.go +++ b/model/cc_trigger.go @@ -83,7 +83,6 @@ func (t Trigger) EntityName() string { } func (t *Trigger) IsValid() AppError { - if t.Name == "" { return NewBadRequestError("trigger.validation.name", "name is required") } diff --git a/utils/lru.go b/utils/lru.go index fd779a54..b7f7d159 100644 --- a/utils/lru.go +++ b/utils/lru.go @@ -8,12 +8,12 @@ import ( // Caching Interface type ObjectCache interface { - AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64) - AddWithDefaultExpires(key, value interface{}) - Add(key, value interface{}) + AddWithExpiresInSecs(key, value any, expireAtSecs int64) + AddWithDefaultExpires(key, value any) + Add(key, value any) Purge() - Get(key interface{}) (value interface{}, ok bool) - Remove(key interface{}) + Get(key any) (value any, ok bool) + Remove(key any) Len() int Name() string GetInvalidateClusterEvent() string @@ -23,7 +23,7 @@ type ObjectCache interface { type Cache struct { size int evictList *list.List - items map[interface{}]*list.Element + items map[any]*list.Element lock sync.RWMutex name string defaultExpiry int64 @@ -34,8 +34,8 @@ type Cache struct { // entry is used to hold a value in the evictList type entry struct { - key interface{} - value interface{} + key any + value any expireAtSecs int64 generation int64 } @@ -45,7 +45,7 @@ func NewLru(size int) *Cache { return &Cache{ size: size, evictList: list.New(), - items: make(map[interface{}]*list.Element, size), + items: make(map[any]*list.Element, size), } } @@ -66,15 +66,15 @@ func (c *Cache) Purge() { c.currentGeneration++ } -func (c *Cache) Add(key, value interface{}) { +func (c *Cache) Add(key, value any) { c.AddWithExpiresInSecs(key, value, 0) } -func (c *Cache) AddWithDefaultExpires(key, value interface{}) { +func (c *Cache) AddWithDefaultExpires(key, value any) { c.AddWithExpiresInSecs(key, value, c.defaultExpiry) } -func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64) { +func (c *Cache) AddWithExpiresInSecs(key, value any, expireAtSecs int64) { c.lock.Lock() defer c.lock.Unlock() @@ -106,7 +106,7 @@ func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64) } } -func (c *Cache) Get(key interface{}) (value interface{}, ok bool) { +func (c *Cache) Get(key any) (value any, ok bool) { c.lock.Lock() defer c.lock.Unlock() @@ -125,7 +125,7 @@ func (c *Cache) Get(key interface{}) (value interface{}, ok bool) { return nil, false } -func (c *Cache) Remove(key interface{}) { +func (c *Cache) Remove(key any) { c.lock.Lock() defer c.lock.Unlock() @@ -135,11 +135,11 @@ func (c *Cache) Remove(key interface{}) { } // Keys returns a slice of the keys in the cache, from oldest to newest. -func (c *Cache) Keys() []interface{} { +func (c *Cache) Keys() []any { c.lock.RLock() defer c.lock.RUnlock() - keys := make([]interface{}, c.len) + keys := make([]any, c.len) i := 0 for ent := c.evictList.Back(); ent != nil; ent = ent.Prev() { e := ent.Value.(*entry) diff --git a/utils/network.go b/utils/network.go index 8cb9abc1..38bb8d4d 100644 --- a/utils/network.go +++ b/utils/network.go @@ -69,7 +69,7 @@ func GetPort() int { // GetFreePort asks the kernel for free open ports that are ready to use. func GetFreePorts(count int) ([]int, error) { var ports []int - for i := 0; i < count; i++ { + for range count { addr, err := net.ResolveTCPAddr("tcp", "localhost:0") if err != nil { return nil, err