client

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryAttempts = 4
	RetryDelay    = 2 * time.Second
)

Variables

This section is empty.

Functions

func TryWithAttempts

func TryWithAttempts(f func() error, attempts uint, delay time.Duration) (err error)

TryWithAttempts tries to get non-error result of calling function f with delay.

func TryWithAttemptsCtx

func TryWithAttemptsCtx(ctx context.Context, f func(context.Context) error, attempts uint, delay time.Duration) (err error)

TryWithAttemptsCtx is helper function that calls TryWithAttempts with function f transformed to closure that does not require ctx as necessary argument.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func BadCli

func BadCli(t testing.TB) *Client

func New

func New(uri string, log *zap.Logger) (*Client, error)

New opens new postgres connection, configures it and return prepared client.

func NewTest

func NewTest(t testing.TB) (*Client, func())

NewTest prepares test client.

If error occurred while creating connection then test will be skipped. Second argument cleanup function to close connection and rollback all changes.

func (*Client) L

func (cli *Client) L() *zap.Logger

L return global client logger.

If client is nil object then global logger will be returned.

func (*Client) P

func (cli *Client) P() *pgxpool.Pool

P returns client's configured logger.

If client is nil object then will be returned nil pool.

Directories

Path Synopsis
fx module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL