Documentation
¶
Overview ¶
package base is the controler for all the XModules of Xamboo and is required to build any other XModule in the system. It controls different datasources for different sites, installed xmodules, logs, caches, databases and tables.
package base is the controler for all the XModules of Xamboo and is required to build any other XModule in the system. It controls different datasources for different sites, installed xmodules, logs, caches, databases and tables.
Package user contains the list of administrative user for the system. All users have accesses, into a profile and even extended access based upon table records. It needs context xmodule.
Index ¶
- Constants
- Variables
- func AddModule(ds applications.Datasource, id string, name string, version string) error
- func GetDatasourceStats(ds *Datasource) *xcore.XDataset
- func GetModule(ds applications.Datasource, id string) *xcore.XDataset
- func ModuleInstalledVersion(ds applications.Datasource, id string) string
- func SynchroTable(ds applications.Datasource, tablename string) (error, []string)
- func TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource
- func VerifyNeeds(ds applications.Datasource, needs []string) (bool, []string)
- type Container
- func (cnt *Container) CreateDatasource(name string, config *xconfig.XConfig) (applications.Datasource, error)
- func (cnt *Container) GetDatasource(id string) applications.Datasource
- func (cnt *Container) GetDatasources() map[string]applications.Datasource
- func (cnt *Container) SetDatasource(id string, ds applications.Datasource)
- func (cnt *Container) TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource
- type ContainersList
- type Datasource
- func (ds *Datasource) AddLanguage(lang language.Tag)
- func (ds *Datasource) CloneShell() applications.Datasource
- func (ds *Datasource) Commit() error
- func (ds *Datasource) GetCache(id string) *xcore.XCache
- func (ds *Datasource) GetCaches() map[string]*xcore.XCache
- func (ds *Datasource) GetDatabase() *xdominion.XBase
- func (ds *Datasource) GetLanguages() []language.Tag
- func (ds *Datasource) GetLog(id string) *log.Logger
- func (ds *Datasource) GetLogs() map[string]*log.Logger
- func (ds *Datasource) GetModule(moduleid string) string
- func (ds *Datasource) GetModules() map[string]string
- func (ds *Datasource) GetName() string
- func (ds *Datasource) GetTable(id string) *xdominion.XTable
- func (ds *Datasource) GetTables() map[string]*xdominion.XTable
- func (ds *Datasource) GetTransaction() *xdominion.XTransaction
- func (ds *Datasource) IsModuleAuthorized(id string) bool
- func (ds *Datasource) Log(id string, messages ...interface{})
- func (ds *Datasource) Rollback() error
- func (ds *Datasource) SetCache(id string, cache *xcore.XCache)
- func (ds *Datasource) SetDatabase(db *xdominion.XBase)
- func (ds *Datasource) SetLog(id string, logger *log.Logger)
- func (ds *Datasource) SetModule(moduleid string, moduleversion string)
- func (ds *Datasource) SetTable(id string, table *xdominion.XTable)
- func (ds *Datasource) StartTransaction() (*xdominion.XTransaction, error)
- type Module
- func (m *Module) GetID() string
- func (m *Module) GetInstalledVersion(ds applications.Datasource) string
- func (m *Module) GetLanguages() map[language.Tag]string
- func (m *Module) GetNeeds() []string
- func (m *Module) GetVersion() string
- func (m *Module) Setup(ds applications.Datasource, prefix string) ([]string, error)
- func (m *Module) StartContext(ds applications.Datasource, ctx *context.Context) error
- func (m *Module) Synchronize(ds applications.Datasource, prefix string) ([]string, error)
- type Modules
- type Structure
Constants ¶
const ( MODULEID = "base" VERSION = "0.1.1" )
Variables ¶
var Containers = &ContainersList{}
var ModuleBase = assets.ModuleEntries{ TryDatasource: TryDatasource, }
var ModulesList = &Modules{}
var Needs = []string{}
Functions ¶
func AddModule ¶
func AddModule(ds applications.Datasource, id string, name string, version string) error
AddModule will insert a record in the modules table and sends back status error
func GetDatasourceStats ¶
func GetDatasourceStats(ds *Datasource) *xcore.XDataset
Analyze a datasource and gets back the main data
func GetModule ¶
func GetModule(ds applications.Datasource, id string) *xcore.XDataset
func ModuleInstalledVersion ¶
func ModuleInstalledVersion(ds applications.Datasource, id string) string
ModuleStatus returns status of the module: "" not installed "version.number" version installed
func SynchroTable ¶
func SynchroTable(ds applications.Datasource, tablename string) (error, []string)
func TryDatasource ¶
func TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource
func VerifyNeeds ¶
func VerifyNeeds(ds applications.Datasource, needs []string) (bool, []string)
Types ¶
type Container ¶
Container if the list of created datasources The XConfig file must have this syntax:
database.[dbid].type=[dbtype] database.[dbid].username=[dbusername] database.[dbid].password=[dbpassword] database.[dbid].database=[dbname] database.[dbid].server=[dbserver] database.[dbid].ssl=[dbsslflag] log.[logid].file=[pathtologfile]
every line can be repeated for each dbid or logid
func Create ¶
Create will scan a full config file for Containers The XConfig file must have this syntax:
datasource=[datasourceid1] datasource=[datasourceid2] datasource=[datasourceid3] datasourceid1-config=[path-to-config-file] datasourceid2-config=[path-to-config-file] datasourceid3-config=[path-to-config-file]
func (*Container) CreateDatasource ¶
func (cnt *Container) CreateDatasource(name string, config *xconfig.XConfig) (applications.Datasource, error)
Createdatasource will create a new datasource, link databases and logs based on XConfig data
func (*Container) GetDatasource ¶
func (cnt *Container) GetDatasource(id string) applications.Datasource
func (*Container) GetDatasources ¶
func (cnt *Container) GetDatasources() map[string]applications.Datasource
func (*Container) SetDatasource ¶
func (cnt *Container) SetDatasource(id string, ds applications.Datasource)
func (*Container) TryDatasource ¶
func (cnt *Container) TryDatasource(ctx *context.Context, datasourcename string) applications.Datasource
TryDatasource will create a new datasource, link databases and logs based on XConfig data
type ContainersList ¶
func (*ContainersList) AddContainer ¶
func (cntl *ContainersList) AddContainer(id string, cnt *Container)
func (*ContainersList) GetContainer ¶
func (cntl *ContainersList) GetContainer(id string) *Container
type Datasource ¶
type Datasource struct {
// The name of the datasource (informative only)
Name string
// A configuration for the datasource: (does not need lock to be accessed since it's a pointer)
Config *xconfig.XConfig
// contains filtered or unexported fields
}
Datasource is a portable structure containing pointer to usefull structures used in any datasource of sites. It must be compilant with assets.Datasource interface Since it's thread safe and based on maps and slices, it must be accessed through Get/Set functions with mutexes to avoid race conditions The is only ONE database by datasource, with a set of modules and tables into this database.
func (*Datasource) AddLanguage ¶
func (ds *Datasource) AddLanguage(lang language.Tag)
func (*Datasource) CloneShell ¶
func (ds *Datasource) CloneShell() applications.Datasource
func (*Datasource) Commit ¶
func (ds *Datasource) Commit() error
func (*Datasource) GetDatabase ¶
func (ds *Datasource) GetDatabase() *xdominion.XBase
func (*Datasource) GetLanguages ¶
func (ds *Datasource) GetLanguages() []language.Tag
func (*Datasource) GetModule ¶
func (ds *Datasource) GetModule(moduleid string) string
func (*Datasource) GetModules ¶
func (ds *Datasource) GetModules() map[string]string
func (*Datasource) GetName ¶
func (ds *Datasource) GetName() string
func (*Datasource) GetTransaction ¶
func (ds *Datasource) GetTransaction() *xdominion.XTransaction
func (*Datasource) IsModuleAuthorized ¶
func (ds *Datasource) IsModuleAuthorized(id string) bool
func (*Datasource) Log ¶
func (ds *Datasource) Log(id string, messages ...interface{})
func (*Datasource) Rollback ¶
func (ds *Datasource) Rollback() error
func (*Datasource) SetDatabase ¶
func (ds *Datasource) SetDatabase(db *xdominion.XBase)
func (*Datasource) SetModule ¶
func (ds *Datasource) SetModule(moduleid string, moduleversion string)
func (*Datasource) StartTransaction ¶
func (ds *Datasource) StartTransaction() (*xdominion.XTransaction, error)
type Module ¶
type Module struct {
ID string
Version string
Languages map[language.Tag]string
Needs []string
FSetup func(applications.Datasource, string) ([]string, error)
FSynchronize func(applications.Datasource, string) ([]string, error)
FStartContext func(applications.Datasource, *context.Context) error
}
func (*Module) GetInstalledVersion ¶
func (m *Module) GetInstalledVersion(ds applications.Datasource) string
func (*Module) GetVersion ¶
func (*Module) Setup ¶
func (m *Module) Setup(ds applications.Datasource, prefix string) ([]string, error)
func (*Module) StartContext ¶
func (m *Module) StartContext(ds applications.Datasource, ctx *context.Context) error
func (*Module) Synchronize ¶
func (m *Module) Synchronize(ds applications.Datasource, prefix string) ([]string, error)
type Modules ¶
type Modules map[string]applications.Module
func (*Modules) Register ¶
func (ml *Modules) Register(m applications.Module)
type Structure ¶
type Structure interface {
// ComplementData adds all the needed data from other objects /duplicable in the thread since the object will be destroyed at the end
ComplementData(ds applications.Datasource)
// IsAuthorized returns true if the structure can be used on this site/language/device
IsAuthorized(ds applications.Datasource, site string, language string, device string) bool
// GetData Returns the raw data
GetData() *xdominion.XRecord
// Clone will clone the whole structure
Clone() Structure
}
Structure interface is made to implement a standarized object to use cross modules, graph, memory caches etc.
