Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container interface { // RegisterFunc registers an initialization func to be run at a specific level. // The lower the level, the earlier the initialization func is run. // // Here is an example: // // const numLevels = 5 // initContainer := initcontainer.New(numLevels) // // const level = 2 // initContainer.RegisterFunc(myInit, level) RegisterFunc(func(), uint) error // Register registers something that fits the Initializer interface (i.e., something // which provides the Init() method) to be run at a specific level. // The lower the level, the earlier the initialization func is run. // // Here is an example: // // const numLevels = 5 // initContainer := initcontainer.New(numLevels) // // type MyInitializer struct { // // Your stuff in here. // } // // func (thing *MyInitializer) Init() { // // some initialization happens here. // } // // myInit := &MyInitializer{} // // const level = 2 // initContainer.RegisterFunc(myInit, level) Register(Initializer, uint) error // Init causes all the initialization funcs (registered with the Register func) // to be run. // // Initialization starts with level 0, then does level 1, then does level 2, etc. Init() error }
func New ¶
New returns a new initialization container.
Each initialization container has a concept of "levels".
Levels are "named" using non-negative integers. I.e., 0, 1, 2, ....
More specifically, the parameter to the New func 'numLevels' determines how many levels there are.
So if, for example, 'numLeves' is 5 then the levels are: 0, 1, 2, 3, 4. (Notice that 5 is NOT a level in this example, because we count the levels starting at 0 (zero).)
type Initializer ¶
type Initializer interface {
Init()
}
Click to show internal directories.
Click to hide internal directories.