54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"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
|
||
|
//TODO Init
|
||
|
return fmt.Errorf("db: Init not implemented")
|
||
|
}
|
||
|
|
||
|
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")
|
||
|
}
|