Documentation
¶
Index ¶
- Constants
- Variables
- func AddQueryResult(resp *response.Response, modelMD *model.ModelMD, modelStruct interface{}, ...) error
- func AddStructFieldsToList(v reflect.Value, fields *[]interface{}, fieldIDs *strings.Builder, ...) error
- func ArgsFieldSep(rfltArgs reflect.Value) string
- func ArgsToInsertParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection, ...) (fieldIds string, fieldArgs string, fieldValues []interface{})
- func ArgsToUpdateParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection) (fieldQuery string, whereQuery string, fieldValues []interface{}, ...)
- func CompleteOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, ...) error
- func CompleteOnArgsWithConn(conn *pgx.Conn, app Applicationer, resp *response.Response, ...) error
- func DeleteOnArgKeys(app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- func DeleteOnArgKeysWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- func GenUniqID(maxLen int) string
- func GetDbLsn(conn *pgx.Conn) string
- func GetExcelFileOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, ...) error
- func GetIntArgValByName(args reflect.Value, fieldName string, defVal int64) int64
- func GetListOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, ...) error
- func GetListQuery(conn *pgx.Conn, rfltArgs reflect.Value, scanModelMD *model.ModelMD, ...) (string, string, []interface{}, int, int, error)
- func GetMd5(data string) string
- func GetModelLsnValue(modelStruct interface{}) string
- func GetModelStructFields(modelStruct interface{}) (model.ModelRow, []interface{})
- func GetObjectOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, ...) error
- func GetObjectOnArgsWithConn(conn *pgx.Conn, app Applicationer, resp *response.Response, ...) error
- func GetSQLDefaultOrderBy(modelMD *model.ModelMD, encryptKey string) string
- func GetSQLLimitFromArgs(rfltArgs reflect.Value, scanModelMD *model.ModelMD, conn *pgx.Conn, ...) (string, int, int, error)
- func GetSQLOrderByFromArgs(rfltArgs reflect.Value, fieldSep string) string
- func GetSQLOrderByFromArgsOrDefault(rfltArgs reflect.Value, fieldSep string, modelMD *model.ModelMD, ...) string
- func GetSQLWhereFromArgs(rfltArgs reflect.Value, fieldSep string, modelMD *model.ModelMD, ...) (string, []interface{}, error)
- func GetTextArgValByName(args reflect.Value, fieldName string, defVal string) string
- func InsertOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- func InsertOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- func MakeStructRowFields(resultStruct interface{}, fieldPrefix string) ([]interface{}, string, error)
- func PublishEventsWithKeys(sockID string, keys map[string]interface{}, app Applicationer, pm PublicMethod, ...)
- func QueryResultToModel(modelMD *model.ModelMD, modelStruct interface{}, query string, ...) (model.Modeler, error)
- func QueryResultToXML(modelID string, scanModel interface{}, query string, queryTotal string, ...) (string, error)
- func RetrieveValue(dStore *pgds.PgProvider, constID string, constVal interface{}) error
- func SetDocPerPageCount(conn *pgx.Conn) error
- func UpdateOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- func UpdateOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, ...) error
- type AppConfiger
- type Application
- func (a *Application) AddServer(ID string, s srv.Server)
- func (a *Application) DestroySession(sessID string)
- func (a *Application) GetAppVersion() string
- func (a *Application) GetBaseDir() string
- func (a *Application) GetConfig() AppConfiger
- func (a *Application) GetDataStorage() interface{}
- func (a *Application) GetEncryptKey() string
- func (a *Application) GetFrameworkVersion() string
- func (a *Application) GetLogger() logger.Logger
- func (a *Application) GetMD() *Metadata
- func (a *Application) GetOnPublishEvent() OnPublishEventProto
- func (a *Application) GetPermisManager() Permissioner
- func (a *Application) GetServer(ID string) srv.Server
- func (a *Application) GetServers() ServerList
- func (a *Application) GetSessManager() *session.Manager
- func (a *Application) GetTempDir() string
- func (a *Application) HandleEvent(fn string, args []byte)
- func (a *Application) HandleJSONRequest(serv srv.Server, sock socket.ClientSocketer, payload []byte, viewID string)
- func (a *Application) HandlePermission(sock socket.ClientSocketer, controllerID string, methodID string) error
- func (a *Application) HandleRequest(serv srv.Server, sock socket.ClientSocketer, controllerID string, ...)
- func (a *Application) HandleRequestCont(serv srv.Server, sock socket.ClientSocketer, pm PublicMethod, contr Controller, ...)
- func (a *Application) HandleServerError(serv srv.Server, sock socket.ClientSocketer, queryID string, viewID string)
- func (a *Application) HandleSession(sock socket.ClientSocketer) error
- func (a *Application) LoadAppVersion() error
- func (a *Application) PublishPublicMethodEvents(pm PublicMethod, params map[string]interface{})
- func (a *Application) ReloadAppConfig() error
- func (a *Application) Run()
- func (a *Application) SendToClient(serv srv.Server, sock socket.ClientSocketer, resp *response.Response, ...) error
- type Applicationer
- type ArgConditions
- type Base_Controller
- type Base_PublicMethod
- type ConditionJoin
- type Constant
- type ConstantBytea
- type ConstantCollection
- type ConstantFloat
- type ConstantInt
- type ConstantInterval
- type ConstantJSON
- type ConstantText
- type ConstantTime
- type Controller
- type ControllerCollection
- func (c *ControllerCollection) ParseCommand(controllerID string, methodID string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)
- func (c *ControllerCollection) ParseFunctionCommand(fn string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)
- func (c *ControllerCollection) ParseJSONCommand(payload []byte) (Controller, PublicMethod, reflect.Value, string, string, error)
- type DbConn
- type DbRow
- type DbRows
- type Enum
- type EnumCollection
- type EnumDescrCollection
- type Enumer
- type ExtCommand
- type LocaleID
- type Metadata
- type ModelMDCollection
- type OnPublishEventProto
- type OnReloadConfigProto
- type Permissioner
- type PublicMethod
- type PublicMethodCollection
- type PublicMethodError
- type PublicMethodEventList
- type PublicMethodID
- type PublicMethodWithEvent
- type RunnableServer
- type SQLDirectType
- type SQLOrder
- type SQLOrders
- type ServerList
- type VersionType
- type XMLer
Constants ¶
const ( DEFAULT_ROLE = "guest" // default user role if not logged SESS_ROLE = "USER_ROLE" // session variable name SESS_LOCALE = "USER_LOCALE" // session variable name VERSION_FILE_NAME = "version.txt" // for storing varion number FRAME_WORK_VERSION = "1.0.0.11" // framwork version )
const ( ER_WRONG_TOKEN_FORMAT = "Неверный формат токена." ER_SESS_NOT_FOUND = "Сессия не нейдена." ER_PARSE_NO_FUNC = "Параметр 'func' не найден." ER_PARSE_NO_METH = "Не найдена функция в параметре." ER_PARSE_NO_CONTR = "Не найден котроллер в параметре." ER_PARSE_CTRL_NOT_DEFINED = "Контроллер '%s' не определен." ER_PARSE_NOT_VALID_EMPTY = "Поле: %s, пустое значение" ER_AUTH = "Ошибка авторизации." //100 ER_AUTH_EXP = "Срок сессии истек." //101 ER_AUTH_NOT_LOGGED = "Не авторизован." //102 ER_AUTH_BANNED = "Доступ запрещен." //103 ER_SQL_SERVER_CON = "Ошибка подключения к серверу базы данных." //105 ER_SQL_QUERY = "Ошибка при выполнении запроса к базе данных." //106 ER_VERSION = "Версии клиентского и серверного ПО отличается." //107 ER_SESSION = "Ошибка работы с данными сессии." //109 ER_COM_NO_CONTROLLER = "Контроллер не определен." //10 ER_COM_METH_PROHIB = "Метод запрещен." //11 ER_COM_NO_VIEW = "Вид не определен." //12 ER_INTERNAL = "Server innner error." //13 ER_DELETE_CONSTR_VIOL = "Удаление невозможно, так как существуют ссылки." //500 ER_DELETE_NOT_FOUND = "Объект не найден." //510 ER_WRITE_CONSTR_VIOL = "Нарушение уникальности ключевых полей." //600 ER_PM_INTERNAL = "Ошибка исполнения метода." //5 ER_CONTOLLER_METH_NOT_DEFINED = "Метод '%s' контроллера '%s' не найден." ER_SQL_WHERE_FILED_CNT_MISMATCH = "Количество полей в условии не совпадает." ER_SQL_WHERE_UNKNOWN_COND = "Неизветсное условие '%s'." ER_UPDATE_EMPTY = "Поля для обновления не установлены." ER_NO_KEYS = "Ключевые поля не установлены." ER_NO_WHERE = "Не определено значение условия." ER_VERSION_FILE_EMPTY = "Файл версии пустой." ER_CONFIG_FILE_NOT_DEFINED = "Файл конфигурации не определен." )
const ( SQL_STATEMENT_LIMIT_2 = "OFFSET %d LIMIT %d" SQL_STATEMENT_LIMIT_1 = "LIMIT %d" DEF_DOC_PER_PAGE_COUNT int = 50 DEF_LIMIT_COUNT int = 5000 )
const ( SQL_STATEMENT = "ORDER BY " SQL_DIR_ASC = "ASC" SQL_DIR_DESC = "DESC" PAR_DIR_ASC = "asc" PAR_DIR_DESC = "desc" )
const ( SGN_PAR_E = "e" //equal SGN_PAR_L = "l" //less SGN_PAR_G = "g" //greater SGN_PAR_LE = "le" //less and equal SGN_PAR_GE = "ge" //greater and equal SGN_PAR_LK = "lk" //like SGN_PAR_NE = "ne" //not equal SGN_PAR_I = "i" // IS SGN_PAR_IN = "in" // in SGN_PAR_INCL = "incl" //include SGN_PAR_ANY = "any" //Any SGN_PAR_OVERLAP = "overlap" //overlap JOIN_PAR_AND = "a" JOIN_PAR_OR = "o" )
const ( KEY_FLD_PREF = "old_" LSN_FIELD = "lsn" METH_COMPLETE_DEF_COUNT = 50 RESP_ER_DELETE_CONSTR_VIOL = 500 RESP_ER_DELETE_NOT_FOUND = 510 RESP_ER_WRITE_CONSTR_VIOL = 600 )
const DEF_APP_SHUTDOWN_TIMEOUT = 15 //30 seconds
const (
DEF_FIELD_SEP = "@@" //default field separator used by clients
)
Variables ¶
var DebugQueries bool // if true, all queries will be logged
var DocPerPageCount int
Default count value @ToDo: subscribe to DocPerPageCount update local event!!!
var DocPerPageCountConstantID string
Functions ¶
func AddQueryResult ¶
func AddStructFieldsToList ¶
func ArgsFieldSep ¶
Helper function. Returns field separator of a condition query
func ArgsToInsertParams ¶
func ArgsToInsertParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection, encryptKey string) (fieldIds string, fieldArgs string, fieldValues []interface{})
Separates public method arguments into fieldIds, fieldArgs, retFieldIds, fieldValues fieldIds is a string containing all ids fieldArgs is a string with parameters ($1,$2...) to be used in query fieldValues interface values function is used for insert PublicMethod
func ArgsToUpdateParams ¶
func ArgsToUpdateParams(rfltArgs reflect.Value, presetConds sql.FilterCondCollection) (fieldQuery string, whereQuery string, fieldValues []interface{}, keys map[string]interface{})
puts old_key to where query pg specific function
func CompleteOnArgs ¶
func CompleteOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, scanModelMD *model.ModelMD, scanModel interface{}, presetConds sql.FilterCondCollection) error
Implements controller complete method Internally calls CompleteOnArgsWithConn
func CompleteOnArgsWithConn ¶
func CompleteOnArgsWithConn(conn *pgx.Conn, app Applicationer, resp *response.Response, rfltArgs reflect.Value, scanModelMD *model.ModelMD, scanModel interface{}, presetConds sql.FilterCondCollection) error
Implements controller complete method args.Ic - insensetive case 1/0 args.Mid 1 - %pattern%, 0 - pattern% scanModelMD scanModel pattern - pattern to match there is also another argument with the same name as model field marked as matchField=true in tag
func DeleteOnArgKeys ¶
func DeleteOnArgKeys(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error
Common function for deleting object from DB based on argument keys
func DeleteOnArgKeysWithConn ¶
func DeleteOnArgKeysWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error
Implements controller delete method
func GetExcelFileOnArgs ¶
func GetIntArgValByName ¶
Helper function to get value as int64 from argument by name
func GetListOnArgs ¶
func GetListOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, modelMD *model.ModelMD, modelStruct interface{}, presetConds sql.FilterCondCollection) error
func GetListQuery ¶
func GetListQuery(conn *pgx.Conn, rfltArgs reflect.Value, scanModelMD *model.ModelMD, extraConds sql.FilterCondCollection, encryptKey string) (string, string, []interface{}, int, int, error)
Returns: query, total query and cond_params string - query, string - total query, []interface{} - condition params from int, count int
func GetModelLsnValue ¶
func GetModelLsnValue(modelStruct interface{}) string
func GetModelStructFields ¶
returns row fields of a given model structute
func GetObjectOnArgs ¶
func GetObjectOnArgs(app Applicationer, resp *response.Response, rfltArgs reflect.Value, modelMD *model.ModelMD, modelStruct interface{}, presetConds sql.FilterCondCollection) error
Implements controller get_object method rfltArgs holds condition fields
func GetObjectOnArgsWithConn ¶
func GetSQLDefaultOrderBy ¶
func GetSQLLimitFromArgs ¶
func GetSQLOrderByFromArgs ¶
func GetSQLWhereFromArgs ¶
func GetSQLWhereFromArgs(rfltArgs reflect.Value, fieldSep string, modelMD *model.ModelMD, extraConds sql.FilterCondCollection) (string, []interface{}, error)
returns:
sql_s query string vals_s slice of validated, sanatized parameters error
func GetTextArgValByName ¶
Helper function to get value as sring from argument by name
func InsertOnArgs ¶
func InsertOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, retModel interface{}, presetConds sql.FilterCondCollection) error
Implements controller insert method internally calls InsertOnArgsWithConn
func InsertOnArgsWithConn ¶
func InsertOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, retModel interface{}, presetConds sql.FilterCondCollection) error
Implements controller insert method
func MakeStructRowFields ¶
func MakeStructRowFields(resultStruct interface{}, fieldPrefix string) ([]interface{}, string, error)
Returns:
struct fields, list of field IDs for select query error if any
func PublishEventsWithKeys ¶
func PublishEventsWithKeys(sockID string, keys map[string]interface{}, app Applicationer, pm PublicMethod, lsn string)
func QueryResultToModel ¶
func QueryResultToModel(modelMD *model.ModelMD, modelStruct interface{}, query string, queryTotal string, condValues []interface{}, conn *pgx.Conn, sysModel bool) (model.Modeler, error)
Executes query and returns it result as model
func QueryResultToXML ¶
func RetrieveValue ¶
func RetrieveValue(dStore *pgds.PgProvider, constID string, constVal interface{}) error
GetValue fetches value of constant constID from store to constVal.
func SetDocPerPageCount ¶
func UpdateOnArgs ¶
func UpdateOnArgs(app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error
Implements controller insert method internally calls UpdateOnArgsWithConn
func UpdateOnArgsWithConn ¶
func UpdateOnArgsWithConn(conn *pgx.Conn, app Applicationer, pm PublicMethod, resp *response.Response, sock socket.ClientSocketer, rfltArgs reflect.Value, modelMD *model.ModelMD, presetConds sql.FilterCondCollection) error
Implements controller insert method
Types ¶
type AppConfiger ¶
type AppConfiger interface {
GetDb() config.DbStorage
GetWSServer() string
GetTLSWSServer() string
GetTLSKey() string
GetTLSCert() string
GetAppID() string
GetLogLevel() string
GetSession() config.Session
GetTemplateDir() string
GetReportErrors() bool
GetXSLTDir() string
GetDefaultLocale() string
GetTechMail() string
GetAuthor() string
GetDebugQueries() bool
GetAppShutdownTimeout() int
SetAppShutdownTimeout(int)
}
AppConfiger is an application configuration interface. Realization is held by Application object.
type Application ¶
type Application struct {
Config AppConfiger // app config
Logger logger.Logger // app logger
SessManager *session.Manager // app sessions
MD *Metadata // app description of all controllers/models
Servers ServerList // list of running servers
PermisManager Permissioner // handles permission rules (controllers to roles)
OnPublishEvent OnPublishEventProto
DataStorage interface{}
EncryptKey string // application encryption key
BaseDir string // application directory
ConfigFileName string //
OnReloadConfig OnReloadConfigProto
AppVersion string
EvntServer RunnableServer
}
Application is the main object holding application parameters. It is passed to all controllers. Derived applications must include this structure to their app objects.
func (*Application) AddServer ¶
func (a *Application) AddServer(ID string, s srv.Server)
AddServer adds a new service to the list.
func (*Application) DestroySession ¶
func (a *Application) DestroySession(sessID string)
DestroySession deletes a session by its ID.
func (*Application) GetAppVersion ¶
func (a *Application) GetAppVersion() string
GetAppVersion returns application version. Version is retrieved from file. It panics if version file is not found. Should be called on application startup.
func (*Application) GetBaseDir ¶
func (a *Application) GetBaseDir() string
func (*Application) GetConfig ¶
func (a *Application) GetConfig() AppConfiger
GetConfig returns application config.
func (*Application) GetDataStorage ¶
func (a *Application) GetDataStorage() interface{}
GetDataStorage returns application data storage object.
func (*Application) GetEncryptKey ¶
func (a *Application) GetEncryptKey() string
func (*Application) GetFrameworkVersion ¶
func (a *Application) GetFrameworkVersion() string
GetFrameworkVersion returns current framwork version number.
func (*Application) GetLogger ¶
func (a *Application) GetLogger() logger.Logger
GetConfig returns application logger.
func (*Application) GetMD ¶
func (a *Application) GetMD() *Metadata
GetConfig returns application metadata.
func (*Application) GetOnPublishEvent ¶
func (a *Application) GetOnPublishEvent() OnPublishEventProto
GetOnPublishEvent returns on publish event function.
func (*Application) GetPermisManager ¶
func (a *Application) GetPermisManager() Permissioner
GetPermisManager returns application permission manager.
func (*Application) GetServer ¶
func (a *Application) GetServer(ID string) srv.Server
GetConfig returns a running service by its name.
func (*Application) GetServers ¶
func (a *Application) GetServers() ServerList
GetConfig returns a list of running service.
func (*Application) GetSessManager ¶
func (a *Application) GetSessManager() *session.Manager
GetSessManager returns application session manager.
func (*Application) GetTempDir ¶
func (a *Application) GetTempDir() string
GetTempDir returns application temp directory. TODO: more platform independant way.
func (*Application) HandleEvent ¶
func (a *Application) HandleEvent(fn string, args []byte)
HandleEvent is an event handler. Called from event server. Event is in format "ControllerID.MethodID". No response is expected, so the function returns none. All errors are logged.
func (*Application) HandleJSONRequest ¶
func (a *Application) HandleJSONRequest(serv srv.Server, sock socket.ClientSocketer, payload []byte, viewID string)
HandleJSONRequest handles requests in json format. Payload argument contains json data. It parses incoming arguments, then on success HandleRequestCont() is called.
func (*Application) HandlePermission ¶
func (a *Application) HandlePermission(sock socket.ClientSocketer, controllerID string, methodID string) error
HandlePermission is called to determine permission for Controller->method. If not permitted an error is returned. TODO: it is better to return bool value instead.
func (*Application) HandleRequest ¶
func (a *Application) HandleRequest(serv srv.Server, sock socket.ClientSocketer, controllerID string, methodID string, queryID string, argsPayload []byte, viewID string)
HandleRequest handles net request. It has controller and method as separated parameters. If error occurs when parsing command it is sent to client. Otherwise, on success handling is continued in HandleRequestCont() function
func (*Application) HandleRequestCont ¶
func (a *Application) HandleRequestCont(serv srv.Server, sock socket.ClientSocketer, pm PublicMethod, contr Controller, argv reflect.Value, resp *response.Response, viewID string)
HandleRequestCont continues handling a client request. Checks permission for controller->method for a given role.
func (*Application) HandleServerError ¶
func (a *Application) HandleServerError(serv srv.Server, sock socket.ClientSocketer, queryID string, viewID string)
HandleServerError is called on any server error. The error is sent to client with a specified view as an internal server error.
func (*Application) HandleSession ¶
func (a *Application) HandleSession(sock socket.ClientSocketer) error
HandleSession is run on a new client call. It finds an appropriate session by client token or creates a new one if it is dead.
func (*Application) LoadAppVersion ¶
func (a *Application) LoadAppVersion() error
LoadAppVersion loads application version from file defined by VERSION_FILE_NAME constant. File is searched in base directory.
func (*Application) PublishPublicMethodEvents ¶
func (a *Application) PublishPublicMethodEvents(pm PublicMethod, params map[string]interface{})
PublishPublicMethodEvents publishes events from public method if there are any.
func (*Application) ReloadAppConfig ¶
func (a *Application) ReloadAppConfig() error
ReloadAppConfig reloads application configuration from file. After reload OnReloadConfig() is called if it points to a function.
func (*Application) Run ¶
func (a *Application) Run()
Run starts all registered servers and waits for an OS interrupt signal. If interrupted all servers are shutdown within the time specified by AppShutdownTimeout configuration parameter.
func (*Application) SendToClient ¶
func (a *Application) SendToClient(serv srv.Server, sock socket.ClientSocketer, resp *response.Response, viewID string) error
SendToClient sends back to client response object rendered with a specific View. TODO: measure request time?
type Applicationer ¶
type Applicationer interface {
GetConfig() AppConfiger
GetLogger() logger.Logger
GetMD() *Metadata
GetServer(string) srv.Server
GetServers() ServerList
SendToClient(srv.Server, socket.ClientSocketer, *response.Response, string) error
HandleRequest(srv.Server, socket.ClientSocketer, string, string, string, []byte, string)
HandleJSONRequest(srv.Server, socket.ClientSocketer, []byte, string)
HandleSession(socket.ClientSocketer) error
DestroySession(sessID string)
HandlePermission(socket.ClientSocketer, string, string) error
HandleServerError(srv.Server, socket.ClientSocketer, string, string)
GetSessManager() *session.Manager
//XSLTransform([]byte, string, string, string) ([]byte, error)
//XSLToPDFTransform(string, string, []string, []byte, string, string, string) ([]byte, error)
GetFrameworkVersion() string
GetPermisManager() Permissioner
GetOnPublishEvent() OnPublishEventProto
GetDataStorage() interface{}
PublishPublicMethodEvents(PublicMethod, map[string]interface{})
GetEncryptKey() string
GetBaseDir() string
LoadAppVersion() error
ReloadAppConfig() error
}
Applicationer interface is used in all standart controller methods as a parameter.
type ArgConditions ¶
type ArgConditions struct {
Fields []string
Signs []sql.SQLCondition
Values []interface{}
InsCases []bool
Joins []ConditionJoin
}
func ParseSQLWhereFromArgs ¶
func ParseSQLWhereFromArgs(rfltArgs reflect.Value, fieldSep string, modelMetadata fields.FieldCollection) (*ArgConditions, error)
parses reflect.Value, extracts data from cond_fields, cond_sgns, cond_ic, cond_vals, cond_joins returns cond_fields - slice of string cond_sgns - slice of sql.SQLCondition cond_vals - slice of interface{} cond_ic - slice of []bool
func (*ArgConditions) FieldValue ¶
func (a *ArgConditions) FieldValue(fieldID string, cond sql.SQLCondition) (interface{}, error)
type Base_Controller ¶
type Base_Controller struct {
ID string
PublicMethods PublicMethodCollection
}
Base_Controller is a parent structure for all controllers.
func (*Base_Controller) GetID ¶
func (c *Base_Controller) GetID() string
func (*Base_Controller) GetPublicMethod ¶
func (c *Base_Controller) GetPublicMethod(publicMethodID PublicMethodID) (PublicMethod, error)
type Base_PublicMethod ¶
type Base_PublicMethod struct {
ID string
Fields fields.FieldCollection
EventList PublicMethodEventList
}
func (*Base_PublicMethod) AddEvent ¶
func (pm *Base_PublicMethod) AddEvent(evId string)
func (*Base_PublicMethod) GetEventList ¶
func (pm *Base_PublicMethod) GetEventList() PublicMethodEventList
func (*Base_PublicMethod) GetFields ¶
func (pm *Base_PublicMethod) GetFields() fields.FieldCollection
func (*Base_PublicMethod) GetID ¶
func (pm *Base_PublicMethod) GetID() PublicMethodID
type ConditionJoin ¶
type ConditionJoin int
const ( CONDITION_JOIN_AND ConditionJoin = iota CONDITION_JOIN_OR )
func (ConditionJoin) Sql ¶
func (c ConditionJoin) Sql() string
type Constant ¶
type Constant interface {
GetAutoload() bool // if constant is sent to client at first request.
Sanatize(string) (string, error) // manages value validation.
}
Constant describes application constant object.
type ConstantBytea ¶
******************************
func (*ConstantBytea) GetAutoload ¶
func (c *ConstantBytea) GetAutoload() bool
func (*ConstantBytea) GetValue ¶
func (c *ConstantBytea) GetValue(app Applicationer) ([]byte, error)
type ConstantCollection ¶
ConstantCollection is a collection of all application constants.
func (ConstantCollection) Exists ¶
func (c ConstantCollection) Exists(ID string) bool
Exists returns true if a given constant exists.
type ConstantFloat ¶
******************************
func (*ConstantFloat) GetAutoload ¶
func (c *ConstantFloat) GetAutoload() bool
func (*ConstantFloat) GetValue ¶
func (c *ConstantFloat) GetValue(app Applicationer) (float64, error)
type ConstantInt ¶
type ConstantInt struct {
ID string // constant ID
Autoload bool // if autoload
Value fields.ValInt // constant value
}
ConstantInt is a constant of integer type.
func (*ConstantInt) GetAutoload ¶
func (c *ConstantInt) GetAutoload() bool
func (*ConstantInt) GetValue ¶
func (c *ConstantInt) GetValue(app Applicationer) (int64, error)
GetValue return constant value. TODO: caching. Clear value on updates through events.
type ConstantJSON ¶
******************************
func (*ConstantJSON) GetAutoload ¶
func (c *ConstantJSON) GetAutoload() bool
func (*ConstantJSON) GetValue ¶
func (c *ConstantJSON) GetValue(app Applicationer) ([]byte, error)
type ConstantText ¶
ConstantText is string value constant
func (*ConstantText) GetAutoload ¶
func (c *ConstantText) GetAutoload() bool
func (*ConstantText) GetValue ¶
func (c *ConstantText) GetValue(app Applicationer) (string, error)
type ConstantTime ¶
func (*ConstantTime) GetAutoload ¶
func (c *ConstantTime) GetAutoload() bool
func (*ConstantTime) GetValue ¶
func (c *ConstantTime) GetValue(app Applicationer) (time.Time, error)
type Controller ¶
type Controller interface {
//InitPublicMethods()
GetPublicMethod(PublicMethodID) (PublicMethod, error)
GetID() string
}
Controller is an application controller interface.
type ControllerCollection ¶
type ControllerCollection map[string]Controller
ControllerCollection is a list of application controllers.
func (*ControllerCollection) ParseCommand ¶
func (c *ControllerCollection) ParseCommand(controllerID string, methodID string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)
ParseCommand parses command from separated controller,method IDs
func (*ControllerCollection) ParseFunctionCommand ¶
func (c *ControllerCollection) ParseFunctionCommand(fn string, argsPayload []byte) (contr Controller, pm PublicMethod, argv reflect.Value, err error)
ParseFunctionCommand parses command from function string of type ControllerID.MethodID.
func (*ControllerCollection) ParseJSONCommand ¶
func (c *ControllerCollection) ParseJSONCommand(payload []byte) (Controller, PublicMethod, reflect.Value, string, string, error)
ParseJSONCommand parses external command from JSON string of arguments argument "func" at least MUST exist! Returns:
public method interface, argv - all parsed arguments not validated, returned as reflect.Value, query id view id error if any
type Enum ¶
type Enum map[string]EnumDescrCollection
func (*Enum) CheckValue ¶
CheckValue checks if a given value is in enum value list of values.
type EnumCollection ¶
EnumCollection is an application enum list.
type EnumDescrCollection ¶
type Enumer ¶
type Enumer interface {
CheckValue(string) bool // checks if value exists in the given Enum
GetDescription(string, string) string // returns description for a specific localeID
}
Enumer
type ExtCommand ¶
type ExtCommand struct {
Func string `json:"func"` //function Controller.method
Query_id string `json:"query_id"`
View_id string `json:"view_id"`
}
ExtCommand represents external client query command.
type Metadata ¶
type Metadata struct {
Debug bool
Owner string // holds owner information
DataSchema string
Version VersionType
Controllers ControllerCollection
Models ModelMDCollection
Enums EnumCollection
Constants ConstantCollection
}
Metadata is the metadata structure. Maps metadata.xml file.
type OnPublishEventProto ¶
type OnReloadConfigProto ¶
type OnReloadConfigProto = func()
type Permissioner ¶
type PublicMethod ¶
type PublicMethod interface {
GetID() PublicMethodID
GetFields() fields.FieldCollection
Unmarshal(payload []byte) (reflect.Value, error)
Run(Applicationer, srv.Server, socket.ClientSocketer, *response.Response, reflect.Value) error
GetEventList() PublicMethodEventList
}
type PublicMethodCollection ¶
type PublicMethodCollection map[PublicMethodID]PublicMethod
type PublicMethodError ¶
func NewPublicMethodError ¶
func NewPublicMethodError(code int, err string) *PublicMethodError
func (PublicMethodError) Error ¶
func (e PublicMethodError) Error() string
type PublicMethodEventList ¶
type PublicMethodEventList []string
type PublicMethodWithEvent ¶
type PublicMethodWithEvent interface {
GetEventList() PublicMethodEventList
AddEvent(string)
}
type RunnableServer ¶
type SQLDirectType ¶
type SQLDirectType byte
const ( DIRECT_ASC SQLDirectType = iota DIRECT_DESC SQLDirectType = iota )
type SQLOrder ¶
type SQLOrder struct {
Expr string
Direct SQLDirectType
}
type ServerList ¶
ServerList is a list of running servers. Defined on application startup.