You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: wait_connection.go
    path of file: ./repos/steampipe/pkg/db/db_common
    
    the code of the file until where you have to start completion: package db_common

import (
	"context"
	"log"
	"sync"
	"time"

	"github.com/jackc/pgx/v5"
	"github.com/jackc/pgx/v5/pgxpool"
	"github.com/pkg/errors"
	"github.com/sethvargo/go-retry"
	"github.com/turbot/steampipe/pkg/constants"
	"github.com/turbot/steampipe/pkg/error_helpers"
	"github.com/turbot/steampipe/pkg/statushooks"
	"github.com/turbot/steampipe/pkg/utils"
)

var ErrServiceInRecoveryMode = errors.New("service is in recovery mode")

type waitConfig struct {
	retryInterval time.Duration
	timeout       time.Duration
}

type WaitOption func(w *waitConfig)

func WithRetryInterval(d time.Duration) WaitOption {
	return func(w *waitConfig) {
		
    
func WaitForConnection(ctx context.Context, connStr string, options ...WaitOption) (conn *pgx.Conn, err error) {
	utils.LogTime("db_common.waitForConnection start")
	defer utils.LogTime("db.waitForConnection end")

	config := &waitConfig{
		retryInterval: constants.DBConnectionRetryBackoff,
		timeout:       constants.DBStartTimeout,
	}

	for _, o := range options {
		o(config)
	}

	backoff := retry.WithMaxDuration(
		config.timeout,
		retry.NewConstant(config.retryInterval),
	)

	// create a connection to the service.
	// Retry after a backoff, but only upto a maximum duration.
	err = retry.Do(ctx, backoff, func(rCtx context.Context) error {
		log.Println("[TRACE] Trying to create client with: ", connStr)
		dbConnection, err := pgx.Connect(rCtx, connStr)
		if err != nil {
			log.Println("[TRACE] could not connect:", err)
			return retry.RetryableError(err)
		}
		log.Println("[TRACE] connected to database")
		conn = dbConnection
		return nil
	})

	return conn, err
}