mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
48 lines
1,021 B
Go
48 lines
1,021 B
Go
package rpcstore
|
|
|
|
import (
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool"
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
|
|
)
|
|
|
|
const CName = "common.commonfile.rpcstore"
|
|
|
|
var log = logger.NewNamed(CName)
|
|
|
|
func New() Service {
|
|
return &service{}
|
|
}
|
|
|
|
type Service interface {
|
|
NewStore() RpcStore
|
|
app.Component
|
|
}
|
|
|
|
type service struct {
|
|
pool pool.Pool
|
|
nodeconf nodeconf.Service
|
|
}
|
|
|
|
func (s *service) Init(a *app.App) (err error) {
|
|
s.pool = a.MustComponent(pool.CName).(pool.Pool)
|
|
s.nodeconf = a.MustComponent(nodeconf.CName).(nodeconf.Service)
|
|
return
|
|
}
|
|
|
|
func (s *service) Name() (name string) {
|
|
return CName
|
|
}
|
|
|
|
func (s *service) NewStore() RpcStore {
|
|
cm := newClientManager(s)
|
|
return &store{
|
|
s: s,
|
|
cm: cm,
|
|
}
|
|
}
|
|
|
|
func (s *service) filePeers() []string {
|
|
return s.nodeconf.GetLast().FilePeers()
|
|
}
|