Documentation ¶
Index ¶
- Constants
- type Config
- type DB
- type InDef
- type Marshaller
- type Method
- type OutDef
- type Result
- type Rows
- type Service
- func (srv *Service) Call(r *http.Request, method string, args map[string]interface{}) (interface{}, error)
- func (srv *Service) CallTx(tx Tx, method string, args map[string]interface{}) (interface{}, error)
- func (srv *Service) DB() DB
- func (srv *Service) FetchMethods(tx Tx, nsp *[]string) (map[string]Method, error)
- func (srv *Service) LoadMethods() error
- func (srv *Service) LoadMethodsTx(tx Tx) error
- func (srv *Service) Method(name string) (Method, bool)
- func (srv *Service) Open() error
- func (srv *Service) SetMarshaller(m Marshaller) *Service
- func (srv *Service) SetSchemaSuffix(suffix string) *Service
- type Tx
Constants ¶
const ( SQLInit = `CREATE SCHEMA %s; SET SEARCH_PATH = %s, public;` SQLReset = `RESET SEARCH_PATH;` // TODO: reset after load )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 OutDef ¶
type OutDef struct { Name string `db:"arg"` Type string `db:"type"` Anno *string `db:"anno" json:",omitempty"` }
OutDef holds function result attributes
type Rows ¶
type Rows interface { StructScan(dest interface{}) error MapScan(dest map[string]interface{}) error Scan(dest ...interface{}) error Close() error Next() bool }
Rows is a local copy of *sql[.Result for mocking Rows holds all of Rows methods used
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 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) LoadMethods ¶
LoadMethods load methods for nsp if given, all of methods otherwise
func (*Service) LoadMethodsTx ¶
LoadMethodsTx load methods within given transaction for nsp if given, all of methods otherwise
func (*Service) SetMarshaller ¶ added in v0.3.1
func (srv *Service) SetMarshaller(m Marshaller) *Service
SetMarshaller sets marshaller
func (*Service) SetSchemaSuffix ¶
SetSchemaSuffix sets suffix for all of used shemas names