diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c1faf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.env +.env.* +!.env.dist + +.vscode/ +__debug_bin \ No newline at end of file diff --git a/src/internal/worker/ext.go b/src/internal/worker/ext.go deleted file mode 100644 index e71faff..0000000 --- a/src/internal/worker/ext.go +++ /dev/null @@ -1,133 +0,0 @@ -package worker - -// import ( -// "bytes" -// "encoding/json" -// "os" -// "time" - -// "git.pbiernat.io/egommerce/go-api-pkg/consul" -// "git.pbiernat.io/egommerce/go-api-pkg/fluentd" -// "git.pbiernat.io/egommerce/go-api-pkg/rabbitmq" -// cnf "git.pbiernat.io/egommerce/order-service/internal/config" -// "git.pbiernat.io/egommerce/order-service/pkg/database" -// "github.com/go-redis/redis/v8" -// ) - -// func WithCache(c *cnf.Config) OptionFn { -// return func(w *Worker) error { -// conn := redis.NewClient(&redis.Options{ -// Addr: c.CacheAddr, -// Password: c.CachePassword, -// DB: 0, -// }) - -// w.Cache = conn - -// return nil -// } -// } - -// func WithDatabase(c *cnf.Config) OptionFn { -// return func(w *Worker) error { -// conn, err := database.Connect(c.DbURL) -// if err != nil { -// w.Logger.Log("Failed to connect to Database server: %v\n", err) -// os.Exit(1) -// } - -// w.Database = conn - -// return nil -// } -// } - -// func WithEventbus(c *cnf.Config) OptionFn { -// return func(w *Worker) error { -// _, chn, err := rabbitmq.Open(c.EventBusURL) -// if err != nil { -// w.Logger.Log("Failed to connect to EventBus server: %v\n", err) -// os.Exit(1) -// } - -// err = rabbitmq.NewExchange(chn, c.EventBusExchange) -// if err != nil { -// w.Logger.Log("Failed to declare EventBus exchange: %v\n", err) -// os.Exit(1) -// } - -// _, err = chn.QueueDeclare( -// c.EventBusQueue, // name -// false, // durable -// false, // delete when unused -// false, // exclusive -// false, // no-wait -// nil, // arguments -// ) -// if err != nil { -// w.Logger.Log("Failed to declare EventBus queue: %v\n", err) -// os.Exit(1) -// } - -// // w.bindQueues() -// rabbitmq.BindQueueToExchange(chn, c.EventBusQueue, c.EventBusExchange, "basket.order.basketCheckout") - -// w.Eventbus = chn - -// return nil -// } -// } - -// func WithLogger(c *cnf.Config) OptionFn { -// return func(w *Worker) error { -// logHost, logPort, err := fluentd.ParseAddr(c.LoggerAddr) -// if err != nil { -// w.Logger.Log("Failed to parse Fluentd address: %s. Err: %v", c.LoggerAddr, err) -// os.Exit(1) -// } - -// logger, err := fluentd.NewLogger(c.Base.GetAppFullName(), logHost, logPort) -// if err != nil { -// w.Logger.Log("Failed to connect to the Fluentd on %s:%d. Err: %v", logHost, logPort, err) -// os.Exit(1) -// } - -// w.Logger = logger - -// return nil -// } -// } - -// func WithRegistry(c *cnf.Config) OptionFn { -// return func(w *Worker) error { -// registry, err := consul.NewService(c.RegistryAddr, c.Base.AppID, c.Base.AppName, c.Base.AppID, "", "", 0) -// if err != nil { -// w.Logger.Log("Error connecting to %s: %v", c.RegistryAddr, err) -// } - -// w.Registry = registry - -// go func(w *Worker) { // Fetch Consul KV config and store it in app config -// ticker := time.NewTicker(time.Second * 15) -// for range ticker.C { -// fetchKVConfig(w) // FIXME: duplicated in server -// } -// }(w) - -// return nil -// } - -// } - -// func fetchKVConfig(w *Worker) { // @FIXME: merge duplication in server.go and worker.go -// config, _, err := w.Registry.KV().Get(w.Config.KVNamespace, nil) -// if err != nil || config == nil { -// return -// } - -// kvCnf := bytes.NewBuffer(config.Value) -// decoder := json.NewDecoder(kvCnf) -// if err := decoder.Decode(&w.Config); err != nil { -// return -// } -// }