Documentation ¶
Index ¶
- Constants
- func SetGlobal(cfg *config.Config)
- func WatchGlobalConfig(etcd *etcd.Etcd, watcher Watcher) error
- type Pi
- func (p *Pi) DB(ctx context.Context) *db.Conn
- func (p *Pi) Etcd(ctx context.Context) *etcd.Etcd
- func (p *Pi) GetDeleteHook(ctx context.Context) db.DeleteHook
- func (p *Pi) GetInsertHook(ctx context.Context) db.InsertHook
- func (p *Pi) GetUpdateHook(ctx context.Context) db.UpdateHook
- func (p *Pi) GlobalConfig() (globalCfg *config.GlobalConfig)
- func (p *Pi) ThreadWatchGlobalConfig(cb globalCfgWatcher)
- type Watcher
Examples ¶
Constants ¶
View Source
const ( EtcdPrefix = "openpitrix/" GlobalConfigKey = "global_config" DlockKey = "dlock_" + GlobalConfigKey )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pi ¶
type Pi struct {
// contains filtered or unexported fields
}
func NewPi ¶
Example ¶
package main import ( "fmt" "openpitrix.io/openpitrix/pkg/config" "openpitrix.io/openpitrix/pkg/logger" "openpitrix.io/openpitrix/pkg/pi" ) func main() { // TODO: Automatic startup dependent services. cfg := config.LoadConf() logger.SetLevelByString("debug") cfg.Mysql.Host = "localhost" cfg.Etcd.Endpoints = "localhost:2379" p := pi.NewPi(cfg) fmt.Println(p.GlobalConfig()) }
Output:
func (*Pi) GetDeleteHook ¶ added in v0.2.0
func (p *Pi) GetDeleteHook(ctx context.Context) db.DeleteHook
func (*Pi) GetInsertHook ¶ added in v0.2.0
func (p *Pi) GetInsertHook(ctx context.Context) db.InsertHook
func (*Pi) GetUpdateHook ¶ added in v0.2.0
func (p *Pi) GetUpdateHook(ctx context.Context) db.UpdateHook
func (*Pi) GlobalConfig ¶
func (p *Pi) GlobalConfig() (globalCfg *config.GlobalConfig)
func (*Pi) ThreadWatchGlobalConfig ¶
func (p *Pi) ThreadWatchGlobalConfig(cb globalCfgWatcher)
type Watcher ¶ added in v0.2.0
type Watcher chan *config.GlobalConfig
Click to show internal directories.
Click to hide internal directories.