Documentation
¶
Overview ¶
Package hbcfg provides helpers to create hb drivers from configuration
candidate hb drivers needs to be registered before use
Usage example on hb unicast driver
import "opensvc.com/opensvc/core/hbcfg"
type (
T struct {hbcfg.T} // Concrete object that implement Configure
tx struct {...} // concrete object that implement Transmitter
tx struct {...} // concrete object that implement Receiver
)
func New() hbcfg.Confer {
var i interface{} = &T{}
return i.(hbcfg.Confer)
}
// register unicast hb driver
func init() { hbcfg.Register("unicast", NewConfer) }
func NewTx(..., timeout time.Duration) *tx { ... }
func NewRx(..., timeout time.Duration) *rx { ... }
func (t *T) Configure(ctx context.Context) {
...
timeout := t.GetDuration("timeout", 5*time.Second)
rx := NewRx(..., timeout)
tx := NewTx(..., timeout)
t.SetTx(rx)
t.SetRx(tx)
}
Index ¶
- func Driver(driverName string) func() Confer
- func Register(driverName string, fn func() Confer)
- type Confer
- type T
- func (t *T) Config() *xconfig.T
- func (t *T) GetBool(s string) bool
- func (t *T) GetDuration(s string, defaultValue time.Duration) time.Duration
- func (t *T) GetInt(s string) int
- func (t *T) GetIntAs(s, impersonate string) int
- func (t *T) GetString(s string) string
- func (t *T) GetStringAs(s, impersonate string) string
- func (t *T) GetStrings(s string) []string
- func (t *T) Interval() time.Duration
- func (t T) Name() string
- func (t *T) Nodes() []string
- func (t *T) Rx() hbtype.Receiver
- func (t *T) SetConfig(c *xconfig.T)
- func (t *T) SetDriver(driver string)
- func (t *T) SetInterval(interval time.Duration)
- func (t *T) SetName(name string)
- func (t *T) SetNodes(nodes []string)
- func (t *T) SetRx(rx hbtype.Receiver)
- func (t *T) SetSignature(s string)
- func (t *T) SetTimeout(timeout time.Duration)
- func (t *T) SetTx(tx hbtype.Transmitter)
- func (t *T) Signature() string
- func (t *T) Timeout() time.Duration
- func (t *T) Tx() hbtype.Transmitter
- func (t T) Type() string
- type TConfer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Confer ¶
type Confer interface {
TConfer
// Configure prepare Receiver and Transmitter concrete objects
// composed hb driver struct have to implement Configure
Configure(ctx context.Context)
}
Confer is the interface a hb driver has to implement type struct composed on T have to implement Configure to satisfy Confer
type T ¶
type T struct {
// contains filtered or unexported fields
}
T struct implement TConfer
func (*T) GetStringAs ¶
func (*T) GetStrings ¶
func (*T) SetInterval ¶
func (*T) SetSignature ¶
SetSignature set a string that identifies config details
func (*T) SetTimeout ¶
func (*T) SetTx ¶
func (t *T) SetTx(tx hbtype.Transmitter)
func (*T) Tx ¶
func (t *T) Tx() hbtype.Transmitter
type TConfer ¶
type TConfer interface {
Name() string
Type() string
Config() *xconfig.T
Interval() time.Duration
Timeout() time.Duration
Tx() hbtype.Transmitter
Rx() hbtype.Receiver
Nodes() []string
Signature() string
SetName(string)
SetDriver(string)
SetConfig(*xconfig.T)
SetRx(receiver hbtype.Receiver)
SetTx(transmitter hbtype.Transmitter)
SetInterval(time.Duration)
SetTimeout(time.Duration)
SetNodes([]string)
SetSignature(string)
}
TConfer interface hold getter and setter for hb configuration T struct implement TConfer
Click to show internal directories.
Click to hide internal directories.