infrastructure

package
v0.0.0-...-9417b80 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(logger usecases.Logger, sqlHandler interfaces.SQLHandler)

Dispatch is handle routing

func Load

func Load(logger usecases.Logger)

Load is load configs from a env file.

func NewLogger

func NewLogger() usecases.Logger

NewLogger return a Logger.

func NewSQLHandler

func NewSQLHandler() (interfaces.SQLHandler, error)

NewSQLHandler returns connection and methos which is related to database handling.

Types

type Logger

type Logger struct{}

A Logger belong to the infrastructure layer.

func (*Logger) LogAccess

func (l *Logger) LogAccess(format string, v ...interface{})

LogAccess is print messages to log.

func (*Logger) LogError

func (l *Logger) LogError(format string, v ...interface{})

LogError is print messages to log.

type Result

type Result struct {
	Result sql.Result
}

A Result belong to the infrastructure layer.

func (Result) LastInsertId

func (r Result) LastInsertId() (int64, error)

LastInsertId returns results of a LastInsertId method.

func (Result) RowsAffected

func (r Result) RowsAffected() (int64, error)

RowsAffected returns results of a RowsAffected method.

type Row

type Row struct {
	Rows *sql.Rows
}

A Row belong to the infrastructure layer.

func (Row) Close

func (r Row) Close() error

Close returns results of a Close method.

func (Row) Err

func (r Row) Err() error

Err returns results of a Err method.

func (Row) Next

func (r Row) Next() bool

Next returns results of a Next method.

func (Row) Scan

func (r Row) Scan(value ...interface{}) error

Scan returns results of a Scan method.

type SQLHandler

type SQLHandler struct {
	Conn *sql.DB
}

A SQLHandler belong to the infrastructure layer.

func (*SQLHandler) Begin

func (s *SQLHandler) Begin() (interfaces.Tx, error)

Begin is begin transaction

func (*SQLHandler) Exec

func (s *SQLHandler) Exec(query string, args ...interface{}) (interfaces.Result, error)

Exec is execute statement

func (*SQLHandler) Query

func (s *SQLHandler) Query(query string, args ...interface{}) (interfaces.Row, error)

Query returns results of a Query method.

type Tx

type Tx struct {
	Tx *sql.Tx
}

A Tx belong to the infrastructure layer.

func (Tx) Commit

func (t Tx) Commit() error

Commit is commit transaction

func (Tx) Exec

func (t Tx) Exec(query string, args ...interface{}) (interfaces.Result, error)

Exec is execute statement with transaction

func (Tx) Rollback

func (t Tx) Rollback() error

Rollback is rollback transaction

Jump to

Keyboard shortcuts

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