refactor: use sigChan for shutdown, ctx fixes

* refactor main entry point for starting services
* minor fixes around ctx propagation
* improve otx marker js subscriber
This commit is contained in:
2023-03-02 15:46:02 +00:00
parent a1b6cb08d8
commit a47e44f262
14 changed files with 223 additions and 217 deletions

View File

@@ -19,18 +19,18 @@ type PostgresPoolOpts struct {
}
// NewPostgresPool creates a reusbale connection pool across the cic-custodial component.
func NewPostgresPool(o PostgresPoolOpts) (*pgxpool.Pool, error) {
func NewPostgresPool(ctx context.Context, o PostgresPoolOpts) (*pgxpool.Pool, error) {
parsedConfig, err := pgxpool.ParseConfig(o.DSN)
if err != nil {
return nil, err
}
dbPool, err := pgxpool.NewWithConfig(context.Background(), parsedConfig)
dbPool, err := pgxpool.NewWithConfig(ctx, parsedConfig)
if err != nil {
return nil, err
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
conn, err := dbPool.Acquire(ctx)