forked from TrueCloudLab/frostfs-node
[#488] reputation/managers: Implement route builders
Add implementation of Builder interface for intermediate trusts. Move all code associated with managers to `common` directory in `cmd` and `pkg/services/reputation` Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6ffc109a75
commit
49d477f466
9 changed files with 106 additions and 31 deletions
|
@ -1,48 +0,0 @@
|
|||
package managers
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Prm groups the required parameters of the Builder's constructor.
|
||||
//
|
||||
// All values must comply with the requirements imposed on them.
|
||||
// Passing incorrect parameter values will result in constructor
|
||||
// failure (error or panic depending on the implementation).
|
||||
type Prm struct {
|
||||
// Manager builder for current node.
|
||||
//
|
||||
// Must not be nil.
|
||||
ManagerBuilder ManagerBuilder
|
||||
}
|
||||
|
||||
// Builder represents component that routes node to its managers.
|
||||
//
|
||||
// For correct operation, Builder must be created using
|
||||
// the constructor (New) based on the required parameters
|
||||
// and optional components. After successful creation,
|
||||
// the Builder is immediately ready to work through API.
|
||||
type Builder struct {
|
||||
managerBuilder ManagerBuilder
|
||||
}
|
||||
|
||||
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
|
||||
|
||||
func panicOnPrmValue(n string, v interface{}) {
|
||||
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
|
||||
}
|
||||
|
||||
// New creates a new instance of the Builder.
|
||||
//
|
||||
// Panics if at least one value of the parameters is invalid.
|
||||
//
|
||||
// The created Builder does not require additional
|
||||
// initialization and is completely ready for work.
|
||||
func New(prm Prm) *Builder {
|
||||
switch {
|
||||
case prm.ManagerBuilder == nil:
|
||||
panicOnPrmValue("ManagerBuilder", prm.ManagerBuilder)
|
||||
}
|
||||
|
||||
return &Builder{
|
||||
managerBuilder: prm.ManagerBuilder,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue