Documentation
¶
Overview ¶
Example ¶
moduleList := Modules{
Module{
Name: "database_conn",
DependsOn: "",
Timeout: 15 * time.Second,
InitInterval: time.Second,
Init: func(entry *logrus.Entry) error {
entry.WithField("module", "database_conn").
Info("try to initialize module")
time.Sleep(500 * time.Millisecond)
return errors.New("ha-ha-ha")
},
},
Module{
Name: "rabbit",
DependsOn: "",
Timeout: 15 * time.Second,
InitInterval: time.Second,
Init: func(entry *logrus.Entry) error {
entry.WithField("module", "rabbit").
Info("try to initialize module")
time.Sleep(500 * time.Millisecond)
return nil
},
},
Module{
Name: "listener",
DependsOn: "database_conn",
Timeout: 15 * time.Second,
InitInterval: time.Second,
Init: func(entry *logrus.Entry) error {
entry.WithField("module", "listener").
Info("try to initialize module")
time.Sleep(500 * time.Millisecond)
return nil
},
},
}
err := moduleList.InitAll()
if err != nil {
log.Fatal("Init failed with error: ", err.Error())
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// Name unique identifier for module.
Name string
// DependsOn is a name of other module which should be initialized before this.
DependsOn string
// InitInterval is initial timeout before second attempt to perform initCall.
InitInterval time.Duration
// Timeout is a deadline for the initialization attempts.
Timeout time.Duration
// Init is a module init function.
Init func(*logrus.Entry) error
}
Module is unit for initialization.
Click to show internal directories.
Click to hide internal directories.
