Update coordinator client
This commit is contained in:
parent
d668449e63
commit
c219bb58be
@ -4,6 +4,7 @@ package coordinatorclient
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/anytypeio/any-sync/app"
|
"github.com/anytypeio/any-sync/app"
|
||||||
|
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
|
||||||
"github.com/anytypeio/any-sync/coordinator/coordinatorproto"
|
"github.com/anytypeio/any-sync/coordinator/coordinatorproto"
|
||||||
"github.com/anytypeio/any-sync/net/pool"
|
"github.com/anytypeio/any-sync/net/pool"
|
||||||
"github.com/anytypeio/any-sync/nodeconf"
|
"github.com/anytypeio/any-sync/nodeconf"
|
||||||
@ -16,7 +17,9 @@ func New() CoordinatorClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CoordinatorClient interface {
|
type CoordinatorClient interface {
|
||||||
SpaceSign(ctx context.Context, spaceId string) (receipt *coordinatorproto.SpaceReceiptWithSignature, err error)
|
ChangeStatus(ctx context.Context, spaceId string, deleteRaw *treechangeproto.RawTreeChangeWithId) (err error)
|
||||||
|
StatusCheck(ctx context.Context, spaceId string) (status *coordinatorproto.SpaceStatusCheckResponse, err error)
|
||||||
|
SpaceSign(ctx context.Context, spaceId string, spaceHeader []byte) (receipt *coordinatorproto.SpaceReceiptWithSignature, err error)
|
||||||
FileLimitCheck(ctx context.Context, spaceId string, identity []byte) (limit uint64, err error)
|
FileLimitCheck(ctx context.Context, spaceId string, identity []byte) (limit uint64, err error)
|
||||||
app.Component
|
app.Component
|
||||||
}
|
}
|
||||||
@ -26,6 +29,29 @@ type coordinatorClient struct {
|
|||||||
nodeConf nodeconf.Service
|
nodeConf nodeconf.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *coordinatorClient) ChangeStatus(ctx context.Context, spaceId string, deleteRaw *treechangeproto.RawTreeChangeWithId) (err error) {
|
||||||
|
cl, err := c.client(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = cl.SpaceStatusChange(ctx, &coordinatorproto.SpaceStatusChangeRequest{
|
||||||
|
SpaceId: spaceId,
|
||||||
|
DeletionChangeId: deleteRaw.Id,
|
||||||
|
DeletionChangePayload: deleteRaw.RawChange,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *coordinatorClient) StatusCheck(ctx context.Context, spaceId string) (response *coordinatorproto.SpaceStatusCheckResponse, err error) {
|
||||||
|
cl, err := c.client(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return cl.SpaceStatusCheck(ctx, &coordinatorproto.SpaceStatusCheckRequest{
|
||||||
|
SpaceId: spaceId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (c *coordinatorClient) Init(a *app.App) (err error) {
|
func (c *coordinatorClient) Init(a *app.App) (err error) {
|
||||||
c.pool = a.MustComponent(pool.CName).(pool.Service).NewPool(CName)
|
c.pool = a.MustComponent(pool.CName).(pool.Service).NewPool(CName)
|
||||||
c.nodeConf = a.MustComponent(nodeconf.CName).(nodeconf.Service)
|
c.nodeConf = a.MustComponent(nodeconf.CName).(nodeconf.Service)
|
||||||
@ -36,13 +62,14 @@ func (c *coordinatorClient) Name() (name string) {
|
|||||||
return CName
|
return CName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *coordinatorClient) SpaceSign(ctx context.Context, spaceId string) (receipt *coordinatorproto.SpaceReceiptWithSignature, err error) {
|
func (c *coordinatorClient) SpaceSign(ctx context.Context, spaceId string, spaceHeader []byte) (receipt *coordinatorproto.SpaceReceiptWithSignature, err error) {
|
||||||
cl, err := c.client(ctx)
|
cl, err := c.client(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, err := cl.SpaceSign(ctx, &coordinatorproto.SpaceSignRequest{
|
resp, err := cl.SpaceSign(ctx, &coordinatorproto.SpaceSignRequest{
|
||||||
SpaceId: spaceId,
|
SpaceId: spaceId,
|
||||||
|
Header: spaceHeader,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user