forked from TrueCloudLab/frostfs-node
Initial commit
Initial public review release v0.10.0
This commit is contained in:
commit
dadfd90dcd
276 changed files with 46331 additions and 0 deletions
24
lib/boot/bootstrap_test.go
Normal file
24
lib/boot/bootstrap_test.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package boot
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/bootstrap"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestBootstrapPeerParams(t *testing.T) {
|
||||
s := BootstrapPeerParams{}
|
||||
|
||||
nodeInfo := &bootstrap.NodeInfo{
|
||||
Address: "address",
|
||||
PubKey: []byte{1, 2, 3},
|
||||
Options: []string{
|
||||
"opt1",
|
||||
"opt2",
|
||||
},
|
||||
}
|
||||
s.SetNodeInfo(nodeInfo)
|
||||
|
||||
require.Equal(t, nodeInfo, s.NodeInfo())
|
||||
}
|
31
lib/boot/bootstrapper.go
Normal file
31
lib/boot/bootstrapper.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package boot
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/bootstrap"
|
||||
"github.com/nspcc-dev/neofs-node/internal"
|
||||
)
|
||||
|
||||
// BootstrapPeerParams is a group of parameters
|
||||
// for storage node bootstrap.
|
||||
type BootstrapPeerParams struct {
|
||||
info *bootstrap.NodeInfo
|
||||
}
|
||||
|
||||
// PeerBootstrapper is an interface of the NeoFS node bootstrap tool.
|
||||
type PeerBootstrapper interface {
|
||||
AddPeer(BootstrapPeerParams) error
|
||||
}
|
||||
|
||||
// ErrNilPeerBootstrapper is returned by functions that expect
|
||||
// a non-nil PeerBootstrapper, but received nil.
|
||||
const ErrNilPeerBootstrapper = internal.Error("peer bootstrapper is nil")
|
||||
|
||||
// SetNodeInfo is a node info setter.
|
||||
func (s *BootstrapPeerParams) SetNodeInfo(v *bootstrap.NodeInfo) {
|
||||
s.info = v
|
||||
}
|
||||
|
||||
// NodeInfo is a node info getter.
|
||||
func (s BootstrapPeerParams) NodeInfo() *bootstrap.NodeInfo {
|
||||
return s.info
|
||||
}
|
46
lib/boot/storage.go
Normal file
46
lib/boot/storage.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package boot
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// StorageBootParams is a group of parameters
|
||||
// for storage node bootstrap operation.
|
||||
type StorageBootParams struct {
|
||||
BootstrapPeerParams
|
||||
}
|
||||
|
||||
// StorageBootController is an entity that performs
|
||||
// registration of a storage node in NeoFS network.
|
||||
type StorageBootController struct {
|
||||
peerBoot PeerBootstrapper
|
||||
|
||||
bootPrm StorageBootParams
|
||||
|
||||
log *zap.Logger
|
||||
}
|
||||
|
||||
// SetPeerBootstrapper is a PeerBootstrapper setter.
|
||||
func (s *StorageBootController) SetPeerBootstrapper(v PeerBootstrapper) {
|
||||
s.peerBoot = v
|
||||
}
|
||||
|
||||
// SetBootParams is a storage node bootstrap parameters setter.
|
||||
func (s *StorageBootController) SetBootParams(v StorageBootParams) {
|
||||
s.bootPrm = v
|
||||
}
|
||||
|
||||
// SetLogger is a logging component setter.
|
||||
func (s *StorageBootController) SetLogger(v *zap.Logger) {
|
||||
s.log = v
|
||||
}
|
||||
|
||||
// Bootstrap registers storage node in NeoFS system.
|
||||
func (s StorageBootController) Bootstrap(context.Context) {
|
||||
// register peer in NeoFS network
|
||||
if err := s.peerBoot.AddPeer(s.bootPrm.BootstrapPeerParams); err != nil && s.log != nil {
|
||||
s.log.Error("could not register storage node in network")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue