Alexey Kim hai 9 meses
pai
achega
21f1e2d049
Modificáronse 6 ficheiros con 22 adicións e 6 borrados
  1. 3 2
      config/clickhouse.go
  2. 1 1
      config/database.go
  3. 2 1
      database/database.go
  4. 1 1
      graph/auth
  5. 1 1
      graph/sports
  6. 14 0
      service/pool.go

+ 3 - 2
config/clickhouse.go

@@ -25,13 +25,14 @@ type ClickhouseConfig struct {
 }
 
 type params struct {
+	Secure       bool   `json:"secure" yaml:"secure"`
 	Compress     string `json:"compress" yaml:"compress"`
 	Timeout      int    `json:"timeout" yaml:"timeout"`
 	ReadTimeout  int    `json:"read_timeout" yaml:"read-timeout"`
 	WriteTimeout int    `json:"write_timeout" yaml:"write-timeout"`
 }
 
-func (c *ClickhouseConfig) Invalidate() error {
+func (c ClickhouseConfig) Invalidate() error {
 	if strings.TrimSpace(c.Username) == "" {
 		c.Username = "default"
 	}
@@ -51,7 +52,7 @@ func (c *ClickhouseConfig) Invalidate() error {
 	return Invalidate(c)
 }
 
-func (p *params) Invalidate() error {
+func (p params) Invalidate() error {
 	if p.Compress == "" {
 		p.Compress = "lz4"
 	}

+ 1 - 1
config/database.go

@@ -4,6 +4,6 @@ type Databases struct {
 	Clickhouse *ClickhouseConfig `json:"clickhouse" yaml:"clickhouse"`
 }
 
-func (db *Databases) Invalidate() error {
+func (db Databases) Invalidate() error {
 	return Invalidate(db)
 }

+ 2 - 1
database/database.go

@@ -4,9 +4,10 @@ import (
 	"context"
 )
 
-type Database interface {
+type Database[T any] interface {
 	String() string
 	Close() error
 
 	Ping(ctx context.Context) error
+	Query(ctx context.Context, query string, args ...any) (T, error)
 }

+ 1 - 1
graph/auth

@@ -1 +1 @@
-Subproject commit 3b6f85de676baf56268ba4441644cb8846c015df
+Subproject commit ef5be4b6e626aaa26a160f1b594d35f08ff67f7e

+ 1 - 1
graph/sports

@@ -1 +1 @@
-Subproject commit de24d06e49e95a3823c0cae31a4874da8554b36b
+Subproject commit 8fcb75af858594af45250aa09fc8d37010123f75

+ 14 - 0
service/pool.go

@@ -1,9 +1,14 @@
 package service
 
 import (
+	"fmt"
 	"github.com/google/uuid"
 )
 
+const (
+	META = "service"
+)
+
 func NewPool(services ...Service) (pool map[string]Service) {
 	pool = make(map[string]Service)
 
@@ -22,3 +27,12 @@ func NewPool(services ...Service) (pool map[string]Service) {
 
 	return
 }
+
+func Pool(v any) (map[string]Service, error) {
+	pool, ok := v.(map[string]Service)
+	if !ok {
+		return nil, fmt.Errorf("illegal state: could not extract service pool")
+	}
+
+	return pool, nil
+}