Go API Documentation

github.com/titpetric/microservice/db

No package summary is available.

Package

Files: 9. Third party imports: 4. Imports from organisation: 0. Tests: 0. Benchmarks: 0.

Vars

Types

FS

FS represents a mapping between filename => contents

Field name Field type Comment
type

map[string]string

No comment on field.

Credentials, ConnectionOptions

This type doesn't have documentation.

Field name Field type Comment
DSN

string

No comment on field.
Driver

string

No comment on field.
Credentials

Credentials

No comment on field.
Connector

func(context.Context, Credentials) (*sql.DB, error)

Connector is an optional parameter to produce our own *sql.DB, which is then wrapped in *sqlx.DB

Retries

int

No comment on field.
RetryDelay

time.Duration

No comment on field.
ConnectTimeout

time.Duration

No comment on field.

migration

This type doesn't have documentation.

Field name Field type Comment
Project

string

No comment on field.
Filename

string

No comment on field.
StatementIndex

int

No comment on field.
Status

string

No comment on field.

Functions

func Connect

Connect connects to a database and produces the handle for injection

Uses: apmsql.Open, context.Context, os.Getenv, sql.DB.

func ConnectWithOptions

ConnectWithOptions connect to host based on ConnectionOptions{}

Uses: errors.New, errors.WithStack, sqlx.ConnectContext, sqlx.DB, sqlx.NewDb.

func ConnectWithRetry

ConnectWithRetry uses retry options set in ConnectionOptions{}

Uses: errors.Errorf, log.Printf, log.Println, time.After, time.Minute, time.Second.

func List

List lists database migration filenames

func Print

Print outputs database migrations for a project to log output

Uses: errors.Errorf, errors.Wrap, fmt.Sprintf, log.Println.

func Run

Run takes migrations for a project and executes them against a database

Uses: errors.Errorf, errors.Wrap, fmt.Sprintf, log.Println, sql.ErrNoRows, strings.Join.

func (FS) Migrations

Migrations returns list of SQL files to execute

Uses: filepath.Match, sort.Strings.

func (FS) ReadFile

ReadFile returns decoded file contents from FS

Uses: base64.StdEncoding, os.ErrNotExist.

Private functions

func addOptionToDSN

References: strings.Contains.

func cleanDSN

References: strings.Replace.

func maskDSN

func statements

References: regexp.MustCompilePOSIX, strings.TrimSpace.