Compare commits
12 Commits
b5852a3e61
...
v0.5.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fa00f323f | |||
| 65105d6982 | |||
| 2ac68aed86 | |||
| bc1b0ff731 | |||
| e97a13d1e8 | |||
| e0d270a2eb | |||
| b829092503 | |||
| e16021ee49 | |||
| 69797a214f | |||
| 53e2d49e36 | |||
| f2ab6a94d5 | |||
| 1954182e1c |
@@ -3,8 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.ego.cloudns.be/egommerce/api-entities/basket"
|
"git.ego.freeddns.org/egommerce/api-entities/basket"
|
||||||
basket "git.ego.cloudns.be/egommerce/api-entities/basket/dto"
|
basket "git.ego.freeddns.org/egommerce/api-entities/basket/dto"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2,21 +2,16 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpClient struct {
|
type HttpClient struct {
|
||||||
ua string
|
userAgent string
|
||||||
redis *redis.Client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHttpClient(ua string, redis *redis.Client) *HttpClient {
|
func NewHttpClient() *HttpClient {
|
||||||
return &HttpClient{ua, redis}
|
return &HttpClient{userAgent: "internal-http-client"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HttpClient) SendGet(api, url string, data, out any) error {
|
func (c *HttpClient) SendGet(api, url string, data, out any) error {
|
||||||
@@ -50,7 +45,7 @@ func (c *HttpClient) SendPost(api, url string, data, out any) (any, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *HttpClient) sendRequest(api, url, method string, data any) (*http.Response, error) {
|
func (c *HttpClient) sendRequest(api, url, method string, data any) (*http.Response, error) {
|
||||||
apiUrl := c.getApiUrl(api) + url
|
apiUrl := api + url // FIXME
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
json, err := json.Marshal(&data)
|
json, err := json.Marshal(&data)
|
||||||
@@ -73,23 +68,3 @@ func (c *HttpClient) sendRequest(api, url, method string, data any) (*http.Respo
|
|||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HttpClient) getApiUrl(api string) string {
|
|
||||||
ctx, key, apiAddr := context.Background(), "internal__"+api+"__ips", api
|
|
||||||
// FIXME: key name ^^
|
|
||||||
cmd := c.redis.LLen(ctx, key)
|
|
||||||
if cmd.Err() == nil {
|
|
||||||
len := int(cmd.Val())
|
|
||||||
if len == 0 {
|
|
||||||
apiAddr = c.redis.LIndex(ctx, key, 0).Val()
|
|
||||||
} else {
|
|
||||||
apiAddr = c.redis.LIndex(ctx, key, int64(rand.Intn(len-0)+0)).Val()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if apiAddr == "" {
|
|
||||||
apiAddr = api // default api run on 80 int port
|
|
||||||
}
|
|
||||||
|
|
||||||
return "https://" + apiAddr
|
|
||||||
}
|
|
||||||
50
client/postgresql/postgres.go
Normal file
50
client/postgresql/postgres.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package postgresql
|
||||||
|
|
||||||
|
// Wrapper around jackx/pgx pool
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/jackc/pgx/v5/pgconn"
|
||||||
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Database struct {
|
||||||
|
*pgxpool.Pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDB(connStr string) *Database {
|
||||||
|
db := &Database{}
|
||||||
|
db.Connect(connStr)
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *Database) Connect(connStr string) (*pgxpool.Pool, error) {
|
||||||
|
pool, err := pgxpool.New(context.Background(), connStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pool, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsDuplicatedRow(err error) error {
|
||||||
|
var pgErr *pgconn.PgError
|
||||||
|
|
||||||
|
if errors.As(err, &pgErr) && pgErr.Code == "23505" {
|
||||||
|
return errors.New("duplicated row found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NoRowsInQuerySet(err error) error {
|
||||||
|
if err == pgx.ErrNoRows {
|
||||||
|
return errors.New("no rows found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -11,6 +11,25 @@ import (
|
|||||||
|
|
||||||
type Message map[string]interface{}
|
type Message map[string]interface{}
|
||||||
|
|
||||||
|
func Connect(url string) (*amqp.Connection, *amqp.Channel, error) {
|
||||||
|
conn, err := amqp.Dial(url)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ch, err := conn.Channel()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to open a channel: %v\n", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return conn, ch, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Close(conn *amqp.Connection) error {
|
||||||
|
return conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func Serialize(msg any) (string, error) { // FIXME move to separate service
|
func Serialize(msg any) (string, error) { // FIXME move to separate service
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
encoder := json.NewEncoder(&b)
|
encoder := json.NewEncoder(&b)
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
package consul
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
consul "github.com/hashicorp/consul/api"
|
|
||||||
"github.com/hashicorp/consul/connect"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
Name string
|
|
||||||
Address string
|
|
||||||
appID string
|
|
||||||
domain string
|
|
||||||
pathPrefix string
|
|
||||||
tls bool
|
|
||||||
port int
|
|
||||||
ttl time.Duration
|
|
||||||
client *consul.Client
|
|
||||||
agent *consul.Agent
|
|
||||||
connect *connect.Service
|
|
||||||
kv *consul.KV
|
|
||||||
|
|
||||||
// hcTicker *time.Ticker
|
|
||||||
// ttlTicker *time.Ticker
|
|
||||||
}
|
|
||||||
|
|
||||||
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
|
||||||
|
|
||||||
func NewService(servAddr, id, name, useDomainOverIp, addr, domain, pathPrefix string, appPort int) (*Service, error) {
|
|
||||||
s := new(Service)
|
|
||||||
s.Name = name
|
|
||||||
s.Address = addr
|
|
||||||
s.appID = id
|
|
||||||
s.domain = domain
|
|
||||||
s.pathPrefix = pathPrefix
|
|
||||||
s.tls = true // FIXME add arg
|
|
||||||
s.port = appPort
|
|
||||||
s.ttl = time.Second * 10
|
|
||||||
|
|
||||||
if useDomainOverIp == "true" { // FIXME types...
|
|
||||||
s.Address = domain
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := consul.NewClient(newClientConfig(servAddr))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
s.client = client
|
|
||||||
s.agent = client.Agent()
|
|
||||||
s.kv = client.KV()
|
|
||||||
|
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newClientConfig(serverAddr string) *consul.Config {
|
|
||||||
conf := consul.DefaultConfig()
|
|
||||||
conf.Address = serverAddr
|
|
||||||
|
|
||||||
return conf
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetID() string {
|
|
||||||
return fmt.Sprintf("%s:%s", s.Name, s.appID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetFullAddr() string {
|
|
||||||
proto := "http"
|
|
||||||
if s.tls {
|
|
||||||
proto = "https"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s://%s:%d/", proto, s.domain, s.port)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Register() error {
|
|
||||||
def := &consul.AgentServiceRegistration{
|
|
||||||
ID: s.GetID(),
|
|
||||||
// Kind: consul.ServiceKindConnectProxy,
|
|
||||||
Name: s.Name,
|
|
||||||
Address: s.Address,
|
|
||||||
Port: s.port,
|
|
||||||
Tags: s.getTags(),
|
|
||||||
Connect: &consul.AgentServiceConnect{Native: true},
|
|
||||||
// Proxy: &consul.AgentServiceConnectProxyConfig{
|
|
||||||
// DestinationServiceName: s.Name,
|
|
||||||
// },
|
|
||||||
Check: &consul.AgentServiceCheck{
|
|
||||||
// Interval: "5s",
|
|
||||||
// Timeout: "1s",
|
|
||||||
TTL: s.ttl.String(),
|
|
||||||
Status: "passing",
|
|
||||||
DeregisterCriticalServiceAfter: "10s",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.agent.ServiceRegister(def); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (s *Service) Unregister() error {
|
|
||||||
// s.ttlTicker.Stop()
|
|
||||||
// s.hcTicker.Stop()
|
|
||||||
|
|
||||||
s.client.Catalog().Deregister(&consul.CatalogDeregistration{
|
|
||||||
Address: s.Address,
|
|
||||||
ServiceID: s.GetID(),
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
return s.agent.ServiceDeregister(s.GetID())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) RegisterHealthChecks() {
|
|
||||||
go func() { // startup register
|
|
||||||
t := time.NewTicker(time.Second)
|
|
||||||
for range t.C {
|
|
||||||
if ok, _ := s.healthCheck(); ok {
|
|
||||||
t.Stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() { // TTL
|
|
||||||
t := time.NewTicker(time.Second * 5)
|
|
||||||
for range t.C {
|
|
||||||
if _, err := s.healthCheck(); err != nil {
|
|
||||||
// fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
|
||||||
t.Stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Connect() (*connect.Service, error) {
|
|
||||||
// l := hclog.New(&hclog.LoggerOptions{
|
|
||||||
// Name: "consul-registry",
|
|
||||||
// Level: hclog.Trace,
|
|
||||||
// })
|
|
||||||
svc, err := connect.NewService(s.Name, s.client)
|
|
||||||
s.connect = svc
|
|
||||||
fmt.Printf("CONNECT SERVER:: %s CERTS:: %v\n", s.Name, svc.ServerTLSConfig())
|
|
||||||
// for k, c := range cnf.Certificates {
|
|
||||||
// fmt.Printf("CONNECT CERT %d: %v", k, c)
|
|
||||||
// }
|
|
||||||
|
|
||||||
return svc, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) KV() *consul.KV {
|
|
||||||
return s.kv
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) healthCheck() (bool, error) {
|
|
||||||
alive := func() bool {
|
|
||||||
client := &http.Client{}
|
|
||||||
healthUrl := fmt.Sprintf("%s%s?name=%s", s.GetFullAddr(), "health", s.Name)
|
|
||||||
// fmt.Printf("HealthCheck URL: %s%s?name=%s", s.GetFullAddr(), "health", s.Name)
|
|
||||||
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
req.Header.Set("User-Agent", "service/internal")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
var body []byte
|
|
||||||
resp.Body.Read(body)
|
|
||||||
|
|
||||||
return resp.StatusCode == http.StatusOK
|
|
||||||
}()
|
|
||||||
|
|
||||||
if alive {
|
|
||||||
if err := s.agent.PassTTL("service:"+s.GetID(), "OK"); err != nil {
|
|
||||||
fmt.Printf("Failed to pass TTL: %v", err)
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.agent.FailTTL("service:"+s.GetID(), ErrServiceUnavailable.Error()); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return false, ErrServiceUnavailable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) getTags() []string {
|
|
||||||
tags := []string{
|
|
||||||
// "traefik.enable=true",
|
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.trustForwardHeader=true",
|
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authRequestHeaders=Cookie",
|
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authResponseHeaders=Set-Cookie, Server",
|
|
||||||
// "traefik.http.middlewares.auth_" + s.Name + ".plugin.auth.handlerURL=" + config.GetEnv("AUTH_HANDLER_URL", "https://identity.service.ego.io/api/v1/traefik"),
|
|
||||||
// "traefik.http.middlewares.stripprefix_" + s.Name + ".stripprefix.prefixes=" + s.pathPrefix,
|
|
||||||
// "traefik.http.middlewares.requestid_" + s.Name + ".plugin.requestid.headerName=X-Request-ID",
|
|
||||||
// "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.attempts=3",
|
|
||||||
// "treafik.http.middlewares.retryif_" + s.Name + ".plugin.retryif.statusCode=503",
|
|
||||||
// "traefik.http.routers." + s.Name + ".rule=Host(`" + s.domain + "`) && PathPrefix(`" + s.pathPrefix + "`)",
|
|
||||||
// "traefik.http.routers." + s.Name + ".entryPoints=https",
|
|
||||||
// "traefik.http.routers." + s.Name + ".tls=true",
|
|
||||||
// "traefik.http.routers." + s.Name + ".service=" + s.Name,
|
|
||||||
// "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name,
|
|
||||||
// "traefik.http.routers." + s.Name + ".middlewares=auth_" + s.Name + ",stripprefix_" + s.Name + ",requestid_" + s.Name + "",
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.server.scheme=https",
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port),
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.passhostheader=true",
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.interval=5s",
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.timeout=1s",
|
|
||||||
// "traefik.http.services." + s.Name + ".loadbalancer.healthcheck.path=/health",
|
|
||||||
// "traefik.tls.certificates.certfile=certs/client.crt",
|
|
||||||
// "traefik.tls.certificates.keyfile=certs/client.key",
|
|
||||||
}
|
|
||||||
|
|
||||||
return tags
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package fluentd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ParseAddr(addr string) (string, int, error) {
|
|
||||||
p := strings.Split(addr, ":")
|
|
||||||
fHost := p[0]
|
|
||||||
fPort, err := strconv.Atoi(p[1])
|
|
||||||
if err != nil {
|
|
||||||
return "", 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return fHost, fPort, nil
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package fluentd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/fluent/fluent-logger-golang/fluent"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Logger struct {
|
|
||||||
fluent *fluent.Fluent
|
|
||||||
appName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewLogger(appName, fHost string, fPort int) (*Logger, error) {
|
|
||||||
config := fluent.Config{
|
|
||||||
FluentHost: fHost,
|
|
||||||
FluentPort: fPort,
|
|
||||||
// WriteTimeout: -1,
|
|
||||||
}
|
|
||||||
fluent, err := fluent.New(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Logger{fluent, appName}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Logger) Log(format string, v ...any) {
|
|
||||||
mapData := map[string]string{
|
|
||||||
"message": fmt.Sprintf(format, v...),
|
|
||||||
}
|
|
||||||
err := l.fluent.Post(l.appName, mapData)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Error sending log: ", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Logger) Close() error {
|
|
||||||
return l.fluent.Close()
|
|
||||||
}
|
|
||||||
18
go.mod
18
go.mod
@@ -1,6 +1,6 @@
|
|||||||
module git.ego.freeddns.org/egommerce/go-api-pkg
|
module git.ego.freeddns.org/egommerce/go-api-pkg
|
||||||
|
|
||||||
go 1.18
|
go 1.24
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fluent/fluent-logger-golang v1.9.0
|
github.com/fluent/fluent-logger-golang v1.9.0
|
||||||
@@ -10,6 +10,11 @@ require (
|
|||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.ego.freeddns.org/egommerce/api-entities v0.3.0 // indirect
|
git.ego.freeddns.org/egommerce/api-entities v0.3.0 // indirect
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
||||||
@@ -53,6 +58,7 @@ require (
|
|||||||
github.com/hashicorp/raft-autopilot v0.1.6 // indirect
|
github.com/hashicorp/raft-autopilot v0.1.6 // indirect
|
||||||
github.com/hashicorp/serf v0.10.1 // indirect
|
github.com/hashicorp/serf v0.10.1 // indirect
|
||||||
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
|
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
|
||||||
|
github.com/jackc/pgx/v5 v5.7.6
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
@@ -76,12 +82,12 @@ require (
|
|||||||
github.com/stretchr/testify v1.8.3 // indirect
|
github.com/stretchr/testify v1.8.3 // indirect
|
||||||
github.com/tinylib/msgp v1.1.6 // indirect
|
github.com/tinylib/msgp v1.1.6 // indirect
|
||||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect
|
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect
|
||||||
golang.org/x/crypto v0.1.0 // indirect
|
golang.org/x/crypto v0.37.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
|
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
|
||||||
golang.org/x/net v0.10.0 // indirect
|
golang.org/x/net v0.21.0 // indirect
|
||||||
golang.org/x/sync v0.2.0 // indirect
|
golang.org/x/sync v0.13.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.32.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.24.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/time v0.3.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||||
google.golang.org/protobuf v1.30.0 // indirect
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
|
|||||||
14
go.sum
14
go.sum
@@ -332,6 +332,12 @@ github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J
|
|||||||
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
|
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
|
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
|
||||||
|
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
@@ -500,6 +506,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
@@ -545,6 +552,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||||
|
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
||||||
|
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@@ -618,6 +627,7 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
|
|||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -639,6 +649,7 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||||
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@@ -695,6 +706,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
|
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
|
||||||
@@ -707,6 +719,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
|
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
||||||
|
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package rabbitmq
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Open(url string) (*amqp.Connection, *amqp.Channel, error) {
|
|
||||||
conn, err := amqp.Dial(url)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
ch, err := conn.Channel()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Failed to open a channel: %v\n", err)
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return conn, ch, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Close(conn *amqp.Connection) error {
|
|
||||||
return conn.Close()
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package redis
|
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "strconv"
|
|
||||||
// "time"
|
|
||||||
|
|
||||||
// "github.com/go-redis/redis/v8"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// func NewCache(host string, port int, password string) *redis.Client {
|
|
||||||
// redis := redis.NewClient(&redis.Options{
|
|
||||||
// Addr: host + ":" + strconv.Itoa(port),
|
|
||||||
// Password: password,
|
|
||||||
// DB: 0,
|
|
||||||
// })
|
|
||||||
// defer redis.Close()
|
|
||||||
|
|
||||||
// return redis
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Get(ctx context.Context, key string) (float64, error) {
|
|
||||||
// // ctx := context.Background() // FIXME
|
|
||||||
// price, err := s.cache.Get(ctx, key).Float64()
|
|
||||||
// if err != nil {
|
|
||||||
// s.log.Log("cache read error(key not exists): %#v", err)
|
|
||||||
// return 0, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return price, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Set(ctx context.Context, key string, value any, exp time.Duration) error {
|
|
||||||
// // ctx := context.Background() // FIXME
|
|
||||||
// s.cache.Set(ctx, key, value, exp)
|
|
||||||
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
Reference in New Issue
Block a user