Skip to content
Snippets Groups Projects
Commit d25ee4ac authored by Jake Taylor's avatar Jake Taylor
Browse files

manually connect new hosts added to the hostpool

parent 142724bf
No related branches found
No related tags found
3 merge requests!231Revert "Update store to print changes to the partners list",!187Xx 3829/triggers,!183manually connect new hosts added to the hostpool
...@@ -74,21 +74,23 @@ type HostPool struct { ...@@ -74,21 +74,23 @@ type HostPool struct {
// PoolParams Allows configuration of HostPool parameters // PoolParams Allows configuration of HostPool parameters
type PoolParams struct { type PoolParams struct {
MaxPoolSize uint32 // Maximum number of Hosts in the HostPool MaxPoolSize uint32 // Maximum number of Hosts in the HostPool
PoolSize uint32 // Allows override of HostPool size. Set to zero for dynamic size calculation PoolSize uint32 // Allows override of HostPool size. Set to zero for dynamic size calculation
ProxyAttempts uint32 // How many proxies will be used in event of send failure ProxyAttempts uint32 // How many proxies will be used in event of send failure
MaxPings uint32 // How many gateways to concurrently test when initializing HostPool. Disabled if zero. MaxPings uint32 // How many gateways to concurrently test when initializing HostPool. Disabled if zero.
HostParams connect.HostParams // Parameters for the creation of new Host objects LazyConnection bool // Flag determining whether Host connections are initialized when added to HostPool
HostParams connect.HostParams // Parameters for the creation of new Host objects
} }
// DefaultPoolParams Returns a default set of PoolParams // DefaultPoolParams Returns a default set of PoolParams
func DefaultPoolParams() PoolParams { func DefaultPoolParams() PoolParams {
p := PoolParams{ p := PoolParams{
MaxPoolSize: 30, MaxPoolSize: 30,
ProxyAttempts: 5, ProxyAttempts: 5,
PoolSize: 0, PoolSize: 0,
MaxPings: 0, MaxPings: 0,
HostParams: connect.GetDefaultHostParams(), LazyConnection: true,
HostParams: connect.GetDefaultHostParams(),
} }
p.HostParams.MaxRetries = 1 p.HostParams.MaxRetries = 1
p.HostParams.MaxSendRetries = 1 p.HostParams.MaxSendRetries = 1
...@@ -548,12 +550,14 @@ func (h *HostPool) replaceHostNoStore(newId *id.ID, oldPoolIndex uint32) error { ...@@ -548,12 +550,14 @@ func (h *HostPool) replaceHostNoStore(newId *id.ID, oldPoolIndex uint32) error {
} }
// Manually connect the new Host // Manually connect the new Host
go func() { if !h.poolParams.LazyConnection {
err := newHost.Connect() go func() {
if err != nil { err := newHost.Connect()
jww.WARN.Printf("Unable to initialize Host connection: %+v", err) if err != nil {
} jww.WARN.Printf("Unable to initialize Host connection: %+v", err)
}() }
}()
}
jww.DEBUG.Printf("Replaced Host at %d [%s] with new Host %s", oldPoolIndex, oldHostIDStr, jww.DEBUG.Printf("Replaced Host at %d [%s] with new Host %s", oldPoolIndex, oldHostIDStr,
newId.String()) newId.String())
...@@ -721,8 +725,8 @@ func readUint32(rng io.Reader) uint32 { ...@@ -721,8 +725,8 @@ func readUint32(rng io.Reader) uint32 {
func readRangeUint32(start, end uint32, rng io.Reader) uint32 { func readRangeUint32(start, end uint32, rng io.Reader) uint32 {
size := end - start size := end - start
// note we could just do the part inside the () here, but then extra // note we could just do the part inside the () here, but then extra
// can == size which means a little bit of range is wastes, either // can == size which means a little range is wasted, either
// choice seems negligible so we went with the "more correct" // choice seems negligible, so we went with the "more correct"
extra := (math.MaxUint32%size + 1) % size extra := (math.MaxUint32%size + 1) % size
limit := math.MaxUint32 - extra limit := math.MaxUint32 - extra
// Loop until we read something inside the limit // Loop until we read something inside the limit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment