manager

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrManagerNotReady            = errors.New("manager not ready")
	ErrTemplateAlreadyInitialized = errors.New("template is already initialized")
	ErrTemplateNotFound           = errors.New("template not found")
	ErrTestNotFound               = errors.New("test database not found")
	ErrTemplateDiscarded          = errors.New("template is discarded, can't be used")
	ErrInvalidTemplateState       = errors.New("unexpected template state")
)

Functions

func New

func New(config ManagerConfig) (*Manager, ManagerConfig)

Types

type Manager

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

func DefaultFromEnv

func DefaultFromEnv() *Manager

func (Manager) ClearTrackedTestDatabases

func (m Manager) ClearTrackedTestDatabases(ctx context.Context, hash string) error

func (Manager) Config added in v1.1.0

func (m Manager) Config() ManagerConfig

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context) error

func (Manager) DiscardTemplateDatabase

func (m Manager) DiscardTemplateDatabase(ctx context.Context, hash string) error

func (*Manager) Disconnect

func (m *Manager) Disconnect(ctx context.Context, ignoreCloseError bool) error

func (Manager) FinalizeTemplateDatabase

func (m Manager) FinalizeTemplateDatabase(ctx context.Context, hash string) (db.TemplateDatabase, error)

func (Manager) GetTestDatabase

func (m Manager) GetTestDatabase(ctx context.Context, hash string) (db.TestDatabase, error)

GetTestDatabase tries to get a ready test DB from an existing pool.

func (*Manager) Initialize

func (m *Manager) Initialize(ctx context.Context) error

func (Manager) InitializeTemplateDatabase

func (m Manager) InitializeTemplateDatabase(ctx context.Context, hash string) (db.TemplateDatabase, error)

func (Manager) Ready

func (m Manager) Ready() bool

func (*Manager) Reconnect

func (m *Manager) Reconnect(ctx context.Context, ignoreDisconnectError bool) error

func (*Manager) RecreateTestDatabase added in v1.1.0

func (m *Manager) RecreateTestDatabase(ctx context.Context, hash string, id int) error

RecreateTestDatabase recreates the test DB according to the template and returns it back to the pool.

func (Manager) ResetAllTracking

func (m Manager) ResetAllTracking(ctx context.Context) error

func (Manager) ReturnTestDatabase

func (m Manager) ReturnTestDatabase(ctx context.Context, hash string, id int) error

ReturnTestDatabase returns the given test DB directly to the pool, without cleaning (recreating it).

type ManagerConfig

type ManagerConfig struct {
	ManagerDatabaseConfig    db.DatabaseConfig `json:"-"` // sensitive
	TemplateDatabaseTemplate string

	DatabasePrefix            string
	TemplateDatabasePrefix    string
	TestDatabaseOwner         string
	TestDatabaseOwnerPassword string        `json:"-"` // sensitive
	TemplateFinalizeTimeout   time.Duration // Time to wait for a template to transition into the 'finalized' state
	TestDatabaseGetTimeout    time.Duration // Time to wait for a ready database

	PoolConfig pool.PoolConfig
}

we explicitly want to access this struct via manager.ManagerConfig, thus we disable revive for the next line

func DefaultManagerConfigFromEnv

func DefaultManagerConfigFromEnv() ManagerConfig

Jump to

Keyboard shortcuts

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