pi

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2019 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

View Source
const (
	EtcdPrefix      = "openpitrix/"
	GlobalConfigKey = "global_config"
	DlockKey        = "dlock_" + GlobalConfigKey
)

Variables

This section is empty.

Functions

func SetGlobal added in v0.2.0

func SetGlobal(cfg *config.Config)

func WatchGlobalConfig added in v0.2.0

func WatchGlobalConfig(etcd *etcd.Etcd, watcher Watcher) error

Types

type Pi

type Pi struct {
	// contains filtered or unexported fields
}

func Global

func Global() *Pi

func NewPi

func NewPi(cfg *config.Config) *Pi
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())
}

func (*Pi) DB added in v0.2.0

func (p *Pi) DB(ctx context.Context) *db.Conn

func (*Pi) Etcd

func (p *Pi) Etcd(ctx context.Context) *etcd.Etcd

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) RegisterRuntimeProvider added in v0.4.0

func (p *Pi) RegisterRuntimeProvider(provider, providerConfig string) error

func (*Pi) SetGlobalCfg added in v0.4.0

func (p *Pi) SetGlobalCfg(ctx context.Context) error

func (*Pi) ThreadWatchGlobalConfig

func (p *Pi) ThreadWatchGlobalConfig(cb globalCfgWatcher)

type Watcher added in v0.2.0

type Watcher chan *config.GlobalConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL