infrastructure

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfMissingInt64

func AppendIfMissingInt64(slice []int64, i int64) []int64

AppendIfMissingInt64 will append to an int64 slice if the wanted element is missing.

func EpochToHumanReadable

func EpochToHumanReadable(epoch int64) string

EpochToHumanReadable will return a RFC822 format date time string from a Unix epoch.

func GetMessageForHTTPStatus

func GetMessageForHTTPStatus(statusCode int) string

GetMessageForHTTPStatus will return an appropriate string based on the given HTTP status code.

func IntSliceToCommaSeparatedString

func IntSliceToCommaSeparatedString(data []int64) string

IntSliceToCommaSeparatedString will convert a slice of int64 items into a comma separated string.

Types

type ApplicationDatabase

type ApplicationDatabase interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Begin(ctx context.Context) (pgx.Tx, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
}

ApplicationDatabase represents the application's database contract, any object implementing the contract can be used as the application's database.

type ApplicationHTTPHandler

type ApplicationHTTPHandler interface {
	Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes
	ServeHTTP(http.ResponseWriter, *http.Request)
	Use(middleware ...gin.HandlerFunc) gin.IRoutes
	Static(relativePath, root string) gin.IRoutes
	Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup
}

ApplicationHTTPHandler represents the application's router contract, any object implementing the contract can be used as the application's HTTP router.

type MockApplicationDatabase

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

func (MockApplicationDatabase) Begin

func (mdb MockApplicationDatabase) Begin(ctx context.Context) (pgx.Tx, error)

func (*MockApplicationDatabase) CalledWith

func (mdb *MockApplicationDatabase) CalledWith() []interface{}

func (MockApplicationDatabase) Exec

func (mdb MockApplicationDatabase) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

func (MockApplicationDatabase) Query

func (mdb MockApplicationDatabase) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

type MockRow

type MockRow struct{}

func (MockRow) Scan

func (mr MockRow) Scan(dest ...interface{}) error

type MockRows

type MockRows struct{}

func (MockRows) Close

func (mr MockRows) Close()

func (MockRows) CommandTag

func (mr MockRows) CommandTag() pgconn.CommandTag

func (MockRows) Err

func (mr MockRows) Err() error

func (MockRows) FieldDescriptions

func (mr MockRows) FieldDescriptions() []pgproto3.FieldDescription

func (MockRows) Next

func (mr MockRows) Next() bool

func (MockRows) RawValues

func (mr MockRows) RawValues() [][]byte

func (MockRows) Scan

func (mr MockRows) Scan(dest ...interface{}) error

func (MockRows) Values

func (mr MockRows) Values() ([]interface{}, error)

type MockTx

type MockTx struct{}

func (MockTx) Begin

func (mtx MockTx) Begin(ctx context.Context) (pgx.Tx, error)

func (MockTx) BeginFunc

func (mtx MockTx) BeginFunc(ctx context.Context, f func(pgx.Tx) error) (err error)

func (MockTx) Commit

func (mtx MockTx) Commit(ctx context.Context) error

func (MockTx) Conn

func (mtx MockTx) Conn() *pgx.Conn

func (MockTx) CopyFrom

func (mtx MockTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

func (MockTx) Exec

func (mtx MockTx) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)

func (MockTx) LargeObjects

func (mtx MockTx) LargeObjects() pgx.LargeObjects

func (MockTx) Prepare

func (mtx MockTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)

func (MockTx) Query

func (mtx MockTx) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

func (MockTx) QueryFunc

func (mtx MockTx) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)

func (MockTx) QueryRow

func (mtx MockTx) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

func (MockTx) Rollback

func (mtx MockTx) Rollback(ctx context.Context) error

func (MockTx) SendBatch

func (mtx MockTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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