infrastructure

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ErrNoDatabase = "Database interface not given"

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Execer
	Open() error
	Begin() (Transaction, error)
	PingContext(ctx context.Context) error
	Close() error
}

Database interface of database

type Dependency

type Dependency interface {
	Run() error
	Close() error
}

Dependency interface of service

	 With the Run() function the service run all it's dependencies:
   connections to databases, another services and so on, Also
   there it must initialize Args.Handler, that represent runnable
   server object. If it returns an error, the server startup
   function will stop executing the steps and the program will
   exit with the os command.Exit().

 With the Close() function, the service closes connections to other
  services, databases, stops running gorutins, frees resources, and
  so on. It also can return error, As well as Run(), Close() can
  return an error, which will terminate the program with an error code

type Execer

type Execer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

type Loader

type Loader interface {
	Load(path string, cfg interface{}) error
}

Loader interface of loading struct

type Router

type Router interface {
	PathHandler(tpl string, handler http.Handler) Router
	PathHandlerFunc(
		tpl string,
		f func(http.ResponseWriter, *http.Request),
	) Router
	PathSubrouter(tpl string) Router
	ANY(path string, f models.ResultFunc) Router
	GET(path string, f models.ResultFunc) Router
	POST(path string, f models.ResultFunc) Router
	PUT(path string, f models.ResultFunc) Router
	DELETE(path string, f models.ResultFunc) Router
	OPTIONS(path string, f models.ResultFunc) Router
	Router() http.Handler
}

type Server

type Server interface {
	Run()
	AddDependencies(dependencies ...Dependency) Server
}

Server represents server interface

type Transaction

type Transaction interface {
	Execer
	Commit() error
	Rollback() error
}

Transaction interface of transaction

Directories

Path Synopsis
implementation

Jump to

Keyboard shortcuts

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