package main import ( "context" "fmt" "log" "git.agecem.com/bottin/agendas/queries" "github.com/jackc/pgx/v5/pgxpool" ) type DBClient struct { Pool *pgxpool.Pool } func (d DBClient) Ping(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() default: if d.Pool == nil { return fmt.Errorf("db: cannot check health using nil connection pool") } return d.Pool.Ping(ctx) } } func (d DBClient) Init(ctx context.Context) error { //TODO check context is not closed //TODO check *DB is not nil log.Println("warning: DBClient [Init] not properly checked") // Init if _, err := d.Pool.Exec(ctx, queries.SQLSchema()); err != nil { return err } return nil } func (d DBClient) CreateTransaction(ctx context.Context, transaction Transaction) error { //TODO check context is not closed //TODO check *DB is not nil //TODO CreateTransaction return fmt.Errorf("db: CreateTransaction not implemented") } func (d DBClient) ReadTransaction(ctx context.Context, membreID string, isPerpetual bool) error { //TODO check context is not closed //TODO check *DB is not nil //TODO ReadTransaction return fmt.Errorf("db: ReadTransaction not implemented") } func (d DBClient) CountTransactions(ctx context.Context) (membresSansAgenda, membresAvecPerpetuel, membresAvecNonPerpetuel, membresAvecTout int, err error) { //TODO check context is not closed //TODO check *DB is not nil //TODO CountTransactions return 0, 0, 0, 0, fmt.Errorf("db: CountTransactions not implemented") }