coord nodeconf source, nodeconf service updates

This commit is contained in:
Sergey Cherepanov 2023-04-08 17:01:40 +02:00
parent 86ac8e0d75
commit c843b27b19
No known key found for this signature in database
GPG Key ID: 87F8EDE8FBDF637C
7 changed files with 248 additions and 70 deletions

View File

@ -23,6 +23,7 @@ type CoordinatorClient interface {
StatusCheck(ctx context.Context, spaceId string) (status *coordinatorproto.SpaceStatusPayload, err error)
SpaceSign(ctx context.Context, payload SpaceSignPayload) (receipt *coordinatorproto.SpaceReceiptWithSignature, err error)
FileLimitCheck(ctx context.Context, spaceId string, identity []byte) (limit uint64, err error)
NetworkConfiguration(ctx context.Context, currentId string) (*coordinatorproto.NetworkConfigurationResponse, error)
app.Component
}
@ -128,6 +129,21 @@ func (c *coordinatorClient) FileLimitCheck(ctx context.Context, spaceId string,
return resp.Limit, nil
}
func (c *coordinatorClient) NetworkConfiguration(ctx context.Context, currentId string) (resp *coordinatorproto.NetworkConfigurationResponse, err error) {
cl, err := c.client(ctx)
if err != nil {
return
}
resp, err = cl.NetworkConfiguration(ctx, &coordinatorproto.NetworkConfigurationRequest{
CurrentId: currentId,
})
if err != nil {
err = rpcerr.Unwrap(err)
return
}
return
}
func (c *coordinatorClient) client(ctx context.Context) (coordinatorproto.DRPCCoordinatorClient, error) {
p, err := c.pool.GetOneOf(ctx, c.nodeConf.CoordinatorPeers())
if err != nil {

View File

@ -771,10 +771,12 @@ func (m *NetworkConfigurationRequest) GetCurrentId() string {
type NetworkConfigurationResponse struct {
// id of current configuration
ConfigurationId string `protobuf:"bytes,1,opt,name=configurationId,proto3" json:"configurationId,omitempty"`
// network id
NetworkId string `protobuf:"bytes,2,opt,name=networkId,proto3" json:"networkId,omitempty"`
// nodes list - it will be empty if the client's currentId is equal configurationId
Nodes []*Node `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
Nodes []*Node `protobuf:"bytes,3,rep,name=nodes,proto3" json:"nodes,omitempty"`
// unix timestamp of the creation time of configuration
CreationTimeUnix uint64 `protobuf:"varint,3,opt,name=creationTimeUnix,proto3" json:"creationTimeUnix,omitempty"`
CreationTimeUnix uint64 `protobuf:"varint,4,opt,name=creationTimeUnix,proto3" json:"creationTimeUnix,omitempty"`
}
func (m *NetworkConfigurationResponse) Reset() { *m = NetworkConfigurationResponse{} }
@ -817,6 +819,13 @@ func (m *NetworkConfigurationResponse) GetConfigurationId() string {
return ""
}
func (m *NetworkConfigurationResponse) GetNetworkId() string {
if m != nil {
return m.NetworkId
}
return ""
}
func (m *NetworkConfigurationResponse) GetNodes() []*Node {
if m != nil {
return m.Nodes
@ -920,64 +929,65 @@ func init() {
}
var fileDescriptor_d94f6f99586adae2 = []byte{
// 911 bytes of a gzipped FileDescriptorProto
// 918 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0x23, 0x45,
0x10, 0xf6, 0xd8, 0x4e, 0x82, 0x6b, 0x22, 0xef, 0xa4, 0x49, 0xc2, 0x60, 0xcc, 0x60, 0x0d, 0xb0,
0x98, 0x80, 0xb2, 0x2b, 0x2f, 0x20, 0x10, 0x17, 0xc0, 0x2c, 0x52, 0x10, 0x0a, 0xd1, 0x24, 0x06,
0x01, 0x07, 0x34, 0x3b, 0x53, 0x49, 0x5a, 0x71, 0xba, 0x87, 0xee, 0x36, 0x9b, 0x1c, 0x90, 0x78,
0x04, 0x4e, 0x1c, 0x90, 0x78, 0x03, 0x1e, 0x81, 0x07, 0xe0, 0x98, 0x23, 0x47, 0x94, 0x48, 0x3c,
0x07, 0xea, 0xf9, 0xb1, 0x7b, 0xec, 0x71, 0x82, 0xb4, 0x17, 0xdb, 0xfd, 0xd5, 0xef, 0x57, 0x55,
0x5d, 0x6d, 0x78, 0x37, 0xe2, 0x5c, 0xc4, 0x94, 0x85, 0x8a, 0x8b, 0x07, 0xc6, 0xef, 0x44, 0x70,
0xc5, 0x1f, 0xa4, 0x9f, 0x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xe3, 0xd6, 0xfe, 0xbe, 0x71, 0x6b, 0xdf, 0xf6, 0x6e,
0xfb, 0x23, 0xf6, 0x64, 0x35, 0xf9, 0x7a, 0xf4, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0x5e,
0x22, 0xba, 0xaf, 0x09, 0x00, 0x00,
}
func (m *SpaceSignRequest) Marshal() (dAtA []byte, err error) {
@ -1454,7 +1464,7 @@ func (m *NetworkConfigurationResponse) MarshalToSizedBuffer(dAtA []byte) (int, e
if m.CreationTimeUnix != 0 {
i = encodeVarintCoordinator(dAtA, i, uint64(m.CreationTimeUnix))
i--
dAtA[i] = 0x18
dAtA[i] = 0x20
}
if len(m.Nodes) > 0 {
for iNdEx := len(m.Nodes) - 1; iNdEx >= 0; iNdEx-- {
@ -1467,9 +1477,16 @@ func (m *NetworkConfigurationResponse) MarshalToSizedBuffer(dAtA []byte) (int, e
i = encodeVarintCoordinator(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
dAtA[i] = 0x1a
}
}
if len(m.NetworkId) > 0 {
i -= len(m.NetworkId)
copy(dAtA[i:], m.NetworkId)
i = encodeVarintCoordinator(dAtA, i, uint64(len(m.NetworkId)))
i--
dAtA[i] = 0x12
}
if len(m.ConfigurationId) > 0 {
i -= len(m.ConfigurationId)
copy(dAtA[i:], m.ConfigurationId)
@ -1758,6 +1775,10 @@ func (m *NetworkConfigurationResponse) Size() (n int) {
if l > 0 {
n += 1 + l + sovCoordinator(uint64(l))
}
l = len(m.NetworkId)
if l > 0 {
n += 1 + l + sovCoordinator(uint64(l))
}
if len(m.Nodes) > 0 {
for _, e := range m.Nodes {
l = e.Size()
@ -3210,6 +3231,38 @@ func (m *NetworkConfigurationResponse) Unmarshal(dAtA []byte) error {
m.ConfigurationId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field NetworkId", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCoordinator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCoordinator
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthCoordinator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.NetworkId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Nodes", wireType)
}
@ -3243,7 +3296,7 @@ func (m *NetworkConfigurationResponse) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 3:
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field CreationTimeUnix", wireType)
}

View File

@ -124,10 +124,12 @@ message NetworkConfigurationRequest {
message NetworkConfigurationResponse {
// id of current configuration
string configurationId = 1;
// network id
string networkId = 2;
// nodes list - it will be empty if the client's currentId is equal configurationId
repeated Node nodes = 2;
repeated Node nodes = 3;
// unix timestamp of the creation time of configuration
uint64 creationTimeUnix = 3;
uint64 creationTimeUnix = 4;
}
// NodeType determines the type of API that a node supports

View File

@ -0,0 +1,56 @@
package nodeconfsource
import (
"context"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/coordinator/coordinatorclient"
"github.com/anytypeio/any-sync/nodeconf"
"time"
)
type NodeConfSource interface {
app.Component
nodeconf.Source
}
type nodeConfSource struct {
cl coordinatorclient.CoordinatorClient
}
func (n *nodeConfSource) Init(a *app.App) (err error) {
n.cl = a.MustComponent(coordinatorclient.CName).(coordinatorclient.CoordinatorClient)
return nil
}
func (n *nodeConfSource) Name() (name string) {
return nodeconf.CNameSource
}
func (n *nodeConfSource) GetLast(ctx context.Context, currentId string) (c nodeconf.Configuration, err error) {
res, err := n.cl.NetworkConfiguration(ctx, currentId)
if err != nil {
return
}
if res.ConfigurationId == currentId {
err = nodeconf.ErrConfigurationNotChanged
return
}
nodes := make([]nodeconf.Node, len(res.Nodes))
for i, node := range res.Nodes {
types := make([]nodeconf.NodeType, len(node.Types))
for j, nt := range node.Types {
types[j] = nodeconf.NodeType(nt)
}
nodes[i] = nodeconf.Node{
PeerId: node.PeerId,
Addresses: node.Addresses,
Types: types,
}
}
return nodeconf.Configuration{
Id: res.ConfigurationId,
NetworkId: res.NetworkId,
Nodes: nodes,
CreationTime: time.Unix(int64(res.CreationTimeUnix), 0),
}, nil
}

View File

@ -21,7 +21,7 @@ type NodeConf interface {
ConsensusPeers() []string
// CoordinatorPeers returns list of coordinator nodes
CoordinatorPeers() []string
// Addresses returns map[peerId][]addr with connection addresses for all known nodes
// PeerAddresses returns peer addresses by peer id
PeerAddresses(peerId string) (addrs []string, ok bool)
// CHash returns nodes consistent table
CHash() chash.CHash

View File

@ -1,12 +1,14 @@
package nodeconf
import (
"context"
commonaccount "github.com/anytypeio/any-sync/accountservice"
"github.com/anytypeio/any-sync/app"
"github.com/anytypeio/any-sync/app/logger"
"github.com/anytypeio/go-chash"
"go.uber.org/zap"
"sync"
"time"
)
const CName = "common.nodeconf"
@ -24,25 +26,63 @@ func New() Service {
type Service interface {
NodeConf
app.Component
app.ComponentRunnable
}
type service struct {
accountId string
config Configuration
source Source
store Store
last NodeConf
mu sync.RWMutex
}
func (s *service) Init(a *app.App) (err error) {
nodesConf := a.MustComponent("config").(ConfigGetter)
s.config = a.MustComponent("config").(ConfigGetter).GetNodeConf()
s.accountId = a.MustComponent(commonaccount.CName).(commonaccount.Service).Account().PeerId
return s.setLastConfiguration(nodesConf.GetNodeConf())
s.source = a.MustComponent(CNameSource).(Source)
s.store = a.MustComponent(CNameStore).(Store)
lastStored, err := s.store.GetLast(context.Background(), s.config.NetworkId)
if err == ErrConfigurationNotFound {
lastStored = s.config
err = nil
}
return s.setLastConfiguration(lastStored)
}
func (s *service) Name() (name string) {
return CName
}
func (s *service) Run(_ context.Context) (err error) {
go s.updateLoop(context.Background())
return
}
func (s *service) updateLoop(ctx context.Context) {
for _ = range time.NewTicker(time.Minute * 10).C {
err := s.updateConfiguration(ctx)
if err != nil {
if err == ErrConfigurationNotChanged {
continue
}
log.Info("can't update configuration", zap.Error(err))
}
}
}
func (s *service) updateConfiguration(ctx context.Context) (err error) {
last, err := s.source.GetLast(ctx, s.Configuration().Id)
if err != nil {
return
}
if err = s.store.SaveLast(ctx, last); err != nil {
return
}
return s.setLastConfiguration(last)
}
func (s *service) setLastConfiguration(c Configuration) (err error) {
s.mu.Lock()
defer s.mu.Unlock()
@ -157,3 +197,7 @@ func (s *service) NodeTypes(nodeId string) []NodeType {
defer s.mu.RUnlock()
return s.last.NodeTypes(nodeId)
}
func (s *service) Close(ctx context.Context) (err error) {
return
}

View File

@ -1,9 +1,16 @@
package nodeconf
import "context"
import (
"context"
"errors"
)
const CNameSource = "common.nodeconf.source"
var (
ErrConfigurationNotChanged = errors.New("configuration not changed")
)
type Source interface {
GetLast(ctx context.Context) (c Configuration, err error)
GetLast(ctx context.Context, currentId string) (c Configuration, err error)
}