Documentation
¶
Index ¶
- Constants
- type Config
- type DB
- type InDef
- type Marshaller
- type Method
- type MyDB
- 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) SetSchemaSuffix(suffix string) *Service
- type Tx
Constants ¶
View Source
const ( SQLInit = `CREATE SCHEMA %s; SET SEARCH_PATH = %s, public;` SQLReset = `RESET SEARCH_PATH;` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DSN string `long:"dsn" default:"" description:"Database connect string, i.e. postgres://user:pass@host/dbname?sslmode=disable"`
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)
}
Marshalle rholds all of database methods used
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 Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds API service methods
func New ¶
func New(cfg Config, log loggers.Contextual, dbh DB) *Service
New returns procapi service
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) SetSchemaSuffix ¶
Method returns method by name
Click to show internal directories.
Click to hide internal directories.
