2019-03-14 06:32:25 +03:00
package lncfg
2019-03-14 06:32:52 +03:00
import "fmt"
2019-03-14 06:32:25 +03:00
const (
// DefaultReadWorkers is the default maximum number of concurrent
// workers used by the daemon's read pool.
2019-03-27 02:40:57 +03:00
DefaultReadWorkers = 100
2019-03-14 06:32:25 +03:00
// DefaultWriteWorkers is the default maximum number of concurrent
// workers used by the daemon's write pool.
2019-04-23 02:30:27 +03:00
DefaultWriteWorkers = 8
2019-03-14 06:32:25 +03:00
// DefaultSigWorkers is the default maximum number of concurrent workers
// used by the daemon's sig pool.
DefaultSigWorkers = 8
)
// Workers exposes CLI configuration for turning resources consumed by worker
// pools.
type Workers struct {
// Read is the maximum number of concurrent read pool workers.
2019-04-23 02:30:27 +03:00
Read int ` long:"read" description:"Maximum number of concurrent read pool workers. This number should be proportional to the number of peers." `
2019-03-14 06:32:25 +03:00
// Write is the maximum number of concurrent write pool workers.
2019-04-23 02:30:27 +03:00
Write int ` long:"write" description:"Maximum number of concurrent write pool workers. This number should be proportional to the number of CPUs on the host. " `
2019-03-14 06:32:25 +03:00
// Sig is the maximum number of concurrent sig pool workers.
2019-04-23 02:30:27 +03:00
Sig int ` long:"sig" description:"Maximum number of concurrent sig pool workers. This number should be proportional to the number of CPUs on the host." `
2019-03-14 06:32:25 +03:00
}
2019-03-14 06:32:52 +03:00
// Validate checks the Workers configuration to ensure that the input values are
// sane.
func ( w * Workers ) Validate ( ) error {
if w . Read <= 0 {
return fmt . Errorf ( "number of read workers (%d) must be " +
"positive" , w . Read )
}
if w . Write <= 0 {
return fmt . Errorf ( "number of write workers (%d) must be " +
"positive" , w . Write )
}
if w . Sig <= 0 {
return fmt . Errorf ( "number of sig workers (%d) must be " +
"positive" , w . Sig )
}
return nil
}
2019-04-02 02:33:50 +03:00
// Compile-time constraint to ensure Workers implements the Validator interface.
var _ Validator = ( * Workers ) ( nil )