database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Overview

Package database is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockPostgreClientItf

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

MockPostgreClientItf is a mock of PostgreClientItf interface.

func NewMockPostgreClientItf

func NewMockPostgreClientItf(ctrl *gomock.Controller) *MockPostgreClientItf

NewMockPostgreClientItf creates a new mock instance.

func (*MockPostgreClientItf) Close

func (m *MockPostgreClientItf) Close()

Close mocks base method.

func (*MockPostgreClientItf) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPostgreClientItf) Get

Get mocks base method.

func (*MockPostgreClientItf) GetReader added in v0.8.0

func (m *MockPostgreClientItf) GetReader(ctx context.Context) (*pgxpool.Pool, error)

GetReader mocks base method.

func (*MockPostgreClientItf) GetWriter added in v0.8.0

func (m *MockPostgreClientItf) GetWriter(ctx context.Context) (*pgxpool.Pool, error)

GetWriter mocks base method.

type MockPostgreClientItfMockRecorder

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

MockPostgreClientItfMockRecorder is the mock recorder for MockPostgreClientItf.

func (*MockPostgreClientItfMockRecorder) Close

Close indicates an expected call of Close.

func (*MockPostgreClientItfMockRecorder) Get

func (mr *MockPostgreClientItfMockRecorder) Get(ctx interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockPostgreClientItfMockRecorder) GetReader added in v0.8.0

func (mr *MockPostgreClientItfMockRecorder) GetReader(ctx interface{}) *gomock.Call

GetReader indicates an expected call of GetReader.

func (*MockPostgreClientItfMockRecorder) GetWriter added in v0.8.0

func (mr *MockPostgreClientItfMockRecorder) GetWriter(ctx interface{}) *gomock.Call

GetWriter indicates an expected call of GetWriter.

type PGXClient

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

func NewPGXClient

func NewPGXClient(ctx context.Context, config ...*PostgreConfiguration) (*PGXClient, error)

NewPGXClient creates a postgre client using pgx. First config parameter will always be used for writer. Second config and next will always be used for reader. If only one configuration is being passed, that configuration will be used for both writer and reader.

func (*PGXClient) Close

func (p *PGXClient) Close()

Close closes all connection to the postgres.

func (*PGXClient) Get

func (p *PGXClient) Get(ctx context.Context) (*pgxpool.Pool, error)

Get returns connection client to postgres.

func (*PGXClient) GetReader added in v0.8.0

func (p *PGXClient) GetReader(_ context.Context) (*pgxpool.Pool, error)

func (*PGXClient) GetWriter added in v0.8.0

func (p *PGXClient) GetWriter(_ context.Context) (*pgxpool.Pool, error)

type PostgreClientItf

type PostgreClientItf interface {
	// Get returns connection client to postgres.
	Get(ctx context.Context) (*pgxpool.Pool, error)

	// GetWriter returns connection client to postgres only for writing.
	GetWriter(ctx context.Context) (*pgxpool.Pool, error)

	// GetReader returns connection client to postgres only for reading.
	GetReader(ctx context.Context) (*pgxpool.Pool, error)

	// Close closes all connection to the postgres.
	Close()
}

PostgreClientItf is a client to interact with PostgreSQL database using pgx.

type PostgreConfiguration

type PostgreConfiguration struct {
	// Address is database connection address.
	// e.g. user=unicorn_user password=magical_password dbname=application_name host=127.0.0.1 port=5432 sslmode=disable
	Address string
	// MinConnection is the minimum size of the pool.
	// The health check will increase the number of connections to this
	// amount if it had dropped below.
	MinConnection int32
	// MaxConnection is the maximum size of the pool.
	MaxConnection int32
	// MaxConnectionLifetime is the duration since creation after which a connection will be automatically closed.
	// Time: second.
	MaxConnectionLifetime int64
	// MaxConnectionIdleTime is the duration after which an idle connection will be automatically closed by the health check.
	// Time: second.
	MaxConnectionIdleTime int64
}

Jump to

Keyboard shortcuts

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