Documentation ¶
Overview ¶
callError usage:
type callError interface { IsNotFound() bool IsBadRequest() bool Code() string Error() string Data() map[string]interface{} } perr, ok := err.(callError) if ok { if perr.IsNotFound() { status = http.StatusNotFound } }
Index ¶
- func FieldNames(rows pgx.Rows) []string
- func ScanMap(rows pgx.Rows, dest *map[string]interface{}) error
- func ScanStruct(rows pgx.Rows, dest interface{}) error
- type Config
- type InDef
- type Marshaller
- type Method
- type Option
- type OutDef
- type PGType
- type Service
- func (srv *Service) Call(r *http.Request, method string, args map[string]interface{}) (interface{}, error)
- func (srv *Service) CallTx(tx pgx.Tx, method string, args map[string]interface{}) (interface{}, error)
- func (srv *Service) FetchMethods(tx pgx.Tx, nsp *[]string) (map[string]Method, error)
- func (srv *Service) LoadMethodsTx(tx pgx.Tx) error
- func (srv *Service) Method(name string) (Method, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldNames ¶ added in v0.3.3
func FieldNames(rows pgx.Rows) []string
func ScanStruct ¶ added in v0.3.3
func ScanStruct(rows pgx.Rows, dest interface{}) error
Types ¶
type Config ¶
type Config struct { DSN string `long:"dsn" default:"postgres://?sslmode=disable" description:"Database connect string"` Driver string `long:"driver" default:"postgres" description:"Database driver"` InDefFunc string `long:"indef" default:"func_args" description:"Argument definition function"` OutDefFunc string `long:"outdef" default:"func_result" description:"Result row definition function"` IndexFunc string `long:"index" default:"index" description:"Available functions list"` FuncSchema string `long:"schema" default:"rpc" description:"Definition functions schema"` ArgSyntax string `long:"arg_syntax" default:":=" description:"Default named args syntax (:= or =>)"` ArgTrimPrefix string `long:"arg_prefix" default:"a_" description:"Trim prefix from arg name"` NameSpaces *[]string `long:"nsp" description:"Proc namespace(s)"` }
Config defines local application flags
type InDef ¶
type InDef struct { Name string `db:"arg"` Type string `db:"type"` Required bool `db:"required"` // TODO: is_required Default *string `db:"def_val" json:",omitempty"` Anno *string `db:"anno" json:",omitempty"` }
InDef holds function argument attributes
type Marshaller ¶
type Marshaller interface { Marshal(typ string, v interface{}) (interface{}, error) Unmarshal(typ string, data interface{}) (rv interface{}, err error) }
Marshaller holds methods for database values marshalling
type Method ¶
type Method struct { Name string `db:"code"` Class string `db:"nspname"` Func string `db:"proname"` Anno string `db:"anno"` IsRO bool `db:"is_ro"` IsSet bool `db:"is_set"` IsStruct bool `db:"is_struct"` Sample *string `db:"sample" json:",omitempty"` Result *string `db:"result" json:",omitempty"` In map[string]InDef //`json:",omitempty"` Out []OutDef //`json:",omitempty"` }
Method holds method attributes
type Option ¶ added in v0.3.3
type Option func(*Service)
Option is a functional options return type
func Marshall ¶ added in v0.3.3
func Marshall(m Marshaller) Option
Marshall allows to change default marshaller
type OutDef ¶
type OutDef struct { Name string `db:"arg"` Type string `db:"type"` Anno *string `db:"anno" json:",omitempty"` }
OutDef holds function result attributes
type PGType ¶ added in v0.3.3
type PGType struct{}
PGType implements marshalling between API and nonstandart postgresql types
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds API service methods
func (*Service) Call ¶
func (srv *Service) Call( r *http.Request, method string, args map[string]interface{}, ) (interface{}, error)
Call calls postgresql stored function
func (*Service) CallTx ¶
func (srv *Service) CallTx( tx pgx.Tx, method string, args map[string]interface{}, ) (interface{}, error)
CallTx calls postgresql stored function within given transaction
func (*Service) FetchMethods ¶
FetchMethods fetches from DB methods definition for given namespaces
func (*Service) LoadMethodsTx ¶
LoadMethodsTx load methods within given transaction for nsp if given, all of methods otherwise