From 738ce16f343ef6c23353b36e27270cb536aaa1c7 Mon Sep 17 00:00:00 2001 From: windyboy Date: Wed, 24 Jul 2024 11:07:04 +0800 Subject: [PATCH] refactor: Update ARR body parsing logic The code changes in `pattern_test.go` update the ARR body parsing logic. The message body parsing now correctly handles ARR bodies with a different pattern format. This ensures accurate extraction of data based on patterns and improves the overall functionality of the code. --- cmd/main/main.go | 3 + configs/config.development.toml | 42 -------- internal/config/config.go | 100 +------------------ internal/domain/sita.go | 3 +- internal/nats/sub.go | 12 ++- internal/repository/hasura.go | 6 +- internal/repository/telegrams.ddl | 26 +++++ pkg/utils/log.go | 153 +++++++++++++++++++++++++++++- 8 files changed, 196 insertions(+), 149 deletions(-) delete mode 100644 configs/config.development.toml create mode 100644 internal/repository/telegrams.ddl diff --git a/cmd/main/main.go b/cmd/main/main.go index 35626c9..347be07 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -3,12 +3,14 @@ package main import ( "caatsm/internal/config" "caatsm/internal/nats" + "caatsm/pkg/utils" "fmt" ) func main() { cfg, err := config.LoadConfig() + log := utils.GetLogger() if err != nil { fmt.Printf("Error loading configuration: %v\n", err) return @@ -21,6 +23,7 @@ func main() { fmt.Println("Loaded configuration successfully") + log.Info("Starting nats subscriber") subscribe := nats.NewNatsHandler(cfg) subscribe.Subscribe() } diff --git a/configs/config.development.toml b/configs/config.development.toml deleted file mode 100644 index 80bcb08..0000000 --- a/configs/config.development.toml +++ /dev/null @@ -1,42 +0,0 @@ -[nats] -url = "nats://localhost:4222" -cluster_id = "test-cluster" -client_id = "test-client" - -[subscription] -topic = "example-topic" -queue_group = "example-group" - -[timeouts] -server_timeout = "30s" -reconnect_wait = "10s" -close_timeout = "10s" -ack_wait_timeout = "5s" - -[[body]] -name = "FPL" -[[body.patterns]] -pattern = "^\\((?P[A-Z]{3})\\-(?P[A-Z]+\\d+)\\-(?P[A-Z]{2})(?:.*\\s*)?\\-(?P[A-Z]+\\d+/?[A-Z]?)\\s*\\-(?P.*)\\s*\\-(?P[A-Z]{4})(?P\\d{4})\\s*\\-(?P[A-Z]+\\d+)(?P[A-Z0-9]+)\\s(?P.*)\\s*\\-(?P[A-Z]{4})(?P\\d{4})\\s(?P[A-Z]{4})\\s*\\-(?PPBN\\/[A-Z0-9]+)\\s(?P