1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Merge branch 'main' of github.com:anyproto/any-sync into GO-3125-shared-spaces-limit

This commit is contained in:
Sergey Cherepanov 2024-04-02 18:45:31 +02:00
commit 3a3be11416
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C
26 changed files with 1304 additions and 404 deletions

View file

@ -23,6 +23,7 @@ proto:
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. net/streampool/testservice/protos/*.proto protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. net/streampool/testservice/protos/*.proto
protoc --gogofaster_out=:. net/secureservice/handshake/handshakeproto/protos/*.proto protoc --gogofaster_out=:. net/secureservice/handshake/handshakeproto/protos/*.proto
protoc --gogofaster_out=:. net/rpc/limiter/limiterproto/protos/*.proto
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. coordinator/coordinatorproto/protos/*.proto protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. coordinator/coordinatorproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. consensus/consensusproto/protos/*.proto protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. consensus/consensusproto/protos/*.proto
protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. identityrepo/identityrepoproto/protos/*.proto protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. identityrepo/identityrepoproto/protos/*.proto

View file

@ -4,14 +4,16 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/anyproto/any-sync/app/logger"
"go.uber.org/zap"
"os" "os"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"strings" "strings"
"sync" "sync"
"time" "time"
"go.uber.org/zap"
"github.com/anyproto/any-sync/app/logger"
) )
var ( var (
@ -227,7 +229,7 @@ func (app *App) Start(ctx context.Context) (err error) {
for i := idx; i >= 0; i-- { for i := idx; i >= 0; i-- {
if serviceClose, ok := app.components[i].(ComponentRunnable); ok { if serviceClose, ok := app.components[i].(ComponentRunnable); ok {
if e := serviceClose.Close(ctx); e != nil { if e := serviceClose.Close(ctx); e != nil {
log.Info("close error", zap.String("component", serviceClose.Name()), zap.Error(e)) log.Error("close error", zap.String("component", serviceClose.Name()), zap.Error(e))
} }
} }
} }
@ -235,6 +237,7 @@ func (app *App) Start(ctx context.Context) (err error) {
for i, s := range app.components { for i, s := range app.components {
if err = s.Init(app); err != nil { if err = s.Init(app); err != nil {
log.Error("can't init service", zap.String("service", s.Name()), zap.Error(err))
closeServices(i) closeServices(i)
return fmt.Errorf("can't init service '%s': %w", s.Name(), err) return fmt.Errorf("can't init service '%s': %w", s.Name(), err)
} }
@ -244,6 +247,7 @@ func (app *App) Start(ctx context.Context) (err error) {
if serviceRun, ok := s.(ComponentRunnable); ok { if serviceRun, ok := s.(ComponentRunnable); ok {
start := time.Now() start := time.Now()
if err = serviceRun.Run(ctx); err != nil { if err = serviceRun.Run(ctx); err != nil {
log.Error("can't run service", zap.String("service", serviceRun.Name()), zap.Error(err))
closeServices(i) closeServices(i)
return fmt.Errorf("can't run service '%s': %w", serviceRun.Name(), err) return fmt.Errorf("can't run service '%s': %w", serviceRun.Name(), err)
} }

View file

@ -275,7 +275,6 @@ func (c *oCache) GC() {
var toClose []*entry var toClose []*entry
for _, e := range c.data { for _, e := range c.data {
if e.isActive() && e.lastUsage.Before(deadline) { if e.isActive() && e.lastUsage.Before(deadline) {
e.close = make(chan struct{})
toClose = append(toClose, e) toClose = append(toClose, e)
} }
} }

View file

@ -11,7 +11,7 @@ import (
"github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/acl/list"
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage" "github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
"github.com/anyproto/any-sync/consensus/consensusproto" "github.com/anyproto/any-sync/consensus/consensusproto"
"github.com/anyproto/any-sync/coordinator/coordinatorclient" "github.com/anyproto/any-sync/node/nodeclient"
) )
const CName = "common.acl.aclclient" const CName = "common.acl.aclclient"
@ -25,8 +25,8 @@ type AclJoiningClient interface {
} }
type aclJoiningClient struct { type aclJoiningClient struct {
coordinatorClient coordinatorclient.CoordinatorClient nodeClient nodeclient.NodeClient
keys *accountdata.AccountKeys keys *accountdata.AccountKeys
} }
func NewAclJoiningClient() AclJoiningClient { func NewAclJoiningClient() AclJoiningClient {
@ -38,13 +38,13 @@ func (c *aclJoiningClient) Name() (name string) {
} }
func (c *aclJoiningClient) Init(a *app.App) (err error) { func (c *aclJoiningClient) Init(a *app.App) (err error) {
c.coordinatorClient = a.MustComponent(coordinatorclient.CName).(coordinatorclient.CoordinatorClient) c.nodeClient = a.MustComponent(nodeclient.CName).(nodeclient.NodeClient)
c.keys = a.MustComponent(accountservice.CName).(accountservice.Service).Account() c.keys = a.MustComponent(accountservice.CName).(accountservice.Service).Account()
return nil return nil
} }
func (c *aclJoiningClient) AclGetRecords(ctx context.Context, spaceId, aclHead string) (recs []*consensusproto.RawRecordWithId, err error) { func (c *aclJoiningClient) AclGetRecords(ctx context.Context, spaceId, aclHead string) (recs []*consensusproto.RawRecordWithId, err error) {
return c.coordinatorClient.AclGetRecords(ctx, spaceId, aclHead) return c.nodeClient.AclGetRecords(ctx, spaceId, aclHead)
} }
func (c *aclJoiningClient) getAcl(ctx context.Context, spaceId string) (l list.AclList, err error) { func (c *aclJoiningClient) getAcl(ctx context.Context, spaceId string) (l list.AclList, err error) {
@ -76,7 +76,7 @@ func (c *aclJoiningClient) CancelJoin(ctx context.Context, spaceId string) (err
if err != nil { if err != nil {
return return
} }
_, err = c.coordinatorClient.AclAddRecord(ctx, spaceId, res) _, err = c.nodeClient.AclAddRecord(ctx, spaceId, res)
return return
} }
@ -99,7 +99,7 @@ func (c *aclJoiningClient) RequestJoin(ctx context.Context, spaceId string, payl
if err != nil { if err != nil {
return return
} }
recWithId, err := c.coordinatorClient.AclAddRecord(ctx, spaceId, rec) recWithId, err := c.nodeClient.AclAddRecord(ctx, spaceId, rec)
if err != nil { if err != nil {
return return
} }
@ -126,6 +126,6 @@ func (c *aclJoiningClient) CancelRemoveSelf(ctx context.Context, spaceId string)
if err != nil { if err != nil {
return return
} }
_, err = c.coordinatorClient.AclAddRecord(ctx, spaceId, newRec) _, err = c.nodeClient.AclAddRecord(ctx, spaceId, newRec)
return return
} }

View file

@ -9,7 +9,7 @@ import (
"github.com/anyproto/any-sync/commonspace/object/acl/syncacl" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl"
"github.com/anyproto/any-sync/commonspace/spacestate" "github.com/anyproto/any-sync/commonspace/spacestate"
"github.com/anyproto/any-sync/consensus/consensusproto" "github.com/anyproto/any-sync/consensus/consensusproto"
"github.com/anyproto/any-sync/coordinator/coordinatorclient" "github.com/anyproto/any-sync/node/nodeclient"
"github.com/anyproto/any-sync/util/crypto" "github.com/anyproto/any-sync/util/crypto"
) )
@ -45,13 +45,13 @@ func NewAclSpaceClient() AclSpaceClient {
} }
type aclSpaceClient struct { type aclSpaceClient struct {
coordinatorClient coordinatorclient.CoordinatorClient nodeClient nodeclient.NodeClient
acl list.AclList acl list.AclList
spaceId string spaceId string
} }
func (c *aclSpaceClient) Init(a *app.App) (err error) { func (c *aclSpaceClient) Init(a *app.App) (err error) {
c.coordinatorClient = a.MustComponent(coordinatorclient.CName).(coordinatorclient.CoordinatorClient) c.nodeClient = a.MustComponent(nodeclient.CName).(nodeclient.NodeClient)
c.acl = a.MustComponent(syncacl.CName).(list.AclList) c.acl = a.MustComponent(syncacl.CName).(list.AclList)
c.spaceId = a.MustComponent(spacestate.CName).(*spacestate.SpaceState).SpaceId c.spaceId = a.MustComponent(spacestate.CName).(*spacestate.SpaceState).SpaceId
return nil return nil
@ -217,7 +217,7 @@ func (c *aclSpaceClient) AddRecord(ctx context.Context, consRec *consensusproto.
} }
func (c *aclSpaceClient) sendRecordAndUpdate(ctx context.Context, spaceId string, rec *consensusproto.RawRecord) (err error) { func (c *aclSpaceClient) sendRecordAndUpdate(ctx context.Context, spaceId string, rec *consensusproto.RawRecord) (err error) {
res, err := c.coordinatorClient.AclAddRecord(ctx, spaceId, rec) res, err := c.nodeClient.AclAddRecord(ctx, spaceId, rec)
if err != nil { if err != nil {
return return
} }

View file

@ -28,6 +28,7 @@ import (
"github.com/anyproto/any-sync/identityrepo/identityrepoproto" "github.com/anyproto/any-sync/identityrepo/identityrepoproto"
"github.com/anyproto/any-sync/net/peer" "github.com/anyproto/any-sync/net/peer"
"github.com/anyproto/any-sync/net/pool" "github.com/anyproto/any-sync/net/pool"
"github.com/anyproto/any-sync/node/nodeclient"
"github.com/anyproto/any-sync/nodeconf" "github.com/anyproto/any-sync/nodeconf"
"github.com/anyproto/any-sync/testutil/accounttest" "github.com/anyproto/any-sync/testutil/accounttest"
) )
@ -447,6 +448,27 @@ func (m mockCoordinatorClient) Name() (name string) {
return coordinatorclient.CName return coordinatorclient.CName
} }
var _ nodeclient.NodeClient = (*mockNodeClient)(nil)
type mockNodeClient struct {
}
func (m mockNodeClient) Init(a *app.App) (err error) {
return
}
func (m mockNodeClient) Name() (name string) {
return nodeclient.CName
}
func (m mockNodeClient) AclGetRecords(ctx context.Context, spaceId, aclHead string) (recs []*consensusproto.RawRecordWithId, err error) {
return
}
func (m mockNodeClient) AclAddRecord(ctx context.Context, spaceId string, rec *consensusproto.RawRecord) (recWithId *consensusproto.RawRecordWithId, err error) {
return
}
// //
// Space fixture // Space fixture
// //
@ -484,6 +506,7 @@ func newFixture(t *testing.T) *spaceFixture {
Register(credentialprovider.NewNoOp()). Register(credentialprovider.NewNoOp()).
Register(&mockStatusServiceProvider{}). Register(&mockStatusServiceProvider{}).
Register(mockCoordinatorClient{}). Register(mockCoordinatorClient{}).
Register(mockNodeClient{}).
Register(fx.configurationService). Register(fx.configurationService).
Register(fx.storageProvider). Register(fx.storageProvider).
Register(fx.peermanagerProvider). Register(fx.peermanagerProvider).

1
go.mod
View file

@ -106,6 +106,7 @@ require (
golang.org/x/mod v0.15.0 // indirect golang.org/x/mod v0.15.0 // indirect
golang.org/x/sync v0.6.0 // indirect golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect golang.org/x/sys v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect golang.org/x/tools v0.17.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect google.golang.org/protobuf v1.32.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect

2
go.sum
View file

@ -369,6 +369,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

15
net/rpc/limiter/config.go Normal file
View file

@ -0,0 +1,15 @@
package limiter
type ConfigGetter interface {
GetLimiterConf() Config
}
type Tokens struct {
TokensPerSecond int `yaml:"rps"`
MaxTokens int `yaml:"burst"`
}
type Config struct {
DefaultTokens Tokens `yaml:"default"`
ResponseTokens map[string]Tokens `yaml:"rpc"`
}

130
net/rpc/limiter/limiter.go Normal file
View file

@ -0,0 +1,130 @@
//go:generate mockgen -destination mock_limiter/mock_limiter.go github.com/anyproto/any-sync/net/rpc/limiter RpcLimiter
package limiter
import (
"context"
"strings"
"sync"
"time"
"golang.org/x/time/rate"
"storj.io/drpc"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/net/peer"
"github.com/anyproto/any-sync/net/rpc/limiter/limiterproto"
"github.com/anyproto/any-sync/util/periodicsync"
)
const (
peerCheckInterval = 10 * time.Second
checkTimeout = 2 * time.Second
)
var log = logger.NewNamed(CName)
const CName = "common.rpc.limiter"
type RpcLimiter interface {
app.ComponentRunnable
// WrapDRPCHandler wraps the given drpc.Handler with additional functionality
WrapDRPCHandler(handler drpc.Handler) drpc.Handler
}
func New() RpcLimiter {
return &limiter{
limiters: make(map[string]*peerLimiter),
peerCheckInterval: peerCheckInterval,
checkTimeout: checkTimeout,
}
}
type peerLimiter struct {
*rate.Limiter
lastUsage time.Time
}
type limiter struct {
drpc.Handler
limiters map[string]*peerLimiter
periodicLoop periodicsync.PeriodicSync
peerCheckInterval time.Duration
checkTimeout time.Duration
cfg Config
mx sync.Mutex
}
func (h *limiter) Run(ctx context.Context) (err error) {
h.periodicLoop.Run()
return nil
}
func (h *limiter) Close(ctx context.Context) (err error) {
h.periodicLoop.Close()
return
}
func (h *limiter) Init(a *app.App) (err error) {
h.periodicLoop = periodicsync.NewPeriodicSyncDuration(h.peerCheckInterval, h.checkTimeout, h.peerLoop, log)
h.cfg = a.MustComponent("config").(ConfigGetter).GetLimiterConf()
return nil
}
func (h *limiter) Name() (name string) {
return CName
}
func (h *limiter) peerLoop(ctx context.Context) error {
h.mx.Lock()
defer h.mx.Unlock()
for rpcPeer, lim := range h.limiters {
if time.Since(lim.lastUsage) > h.peerCheckInterval {
delete(h.limiters, rpcPeer)
}
}
return nil
}
func (h *limiter) WrapDRPCHandler(handler drpc.Handler) drpc.Handler {
h.mx.Lock()
defer h.mx.Unlock()
h.Handler = handler
return h
}
func (h *limiter) HandleRPC(stream drpc.Stream, rpc string) (err error) {
peerId, err := peer.CtxPeerId(stream.Context())
if err != nil {
return err
}
lim := h.getPeerLimiter(peerId, rpc)
if !lim.Allow() {
return limiterproto.ErrLimitExceeded
}
return h.Handler.HandleRPC(stream, rpc)
}
func (h *limiter) getLimits(rpc string) Tokens {
if tokens, exists := h.cfg.ResponseTokens[rpc]; exists {
return tokens
}
return h.cfg.DefaultTokens
}
func (h *limiter) getPeerLimiter(peerId string, rpc string) *peerLimiter {
// rpc looks like this /anyNodeSync.NodeSync/PartitionSync
rpcPeer := strings.Join([]string{peerId, rpc}, "-")
h.mx.Lock()
defer h.mx.Unlock()
lim, ok := h.limiters[rpcPeer]
if !ok {
limits := h.getLimits(rpc)
lim = &peerLimiter{
Limiter: rate.NewLimiter(rate.Limit(limits.TokensPerSecond), limits.MaxTokens),
}
h.limiters[rpcPeer] = lim
}
lim.lastUsage = time.Now()
return lim
}

View file

@ -0,0 +1,181 @@
package limiter
import (
"context"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"storj.io/drpc"
"github.com/anyproto/any-sync/net/peer"
"github.com/anyproto/any-sync/net/rpc/limiter/limiterproto"
)
var ctx = context.Background()
type mockHandler struct {
calls atomic.Int32
}
type mockStream struct {
ctx context.Context
}
func (m mockStream) Context() context.Context {
return m.ctx
}
func (m mockStream) MsgSend(msg drpc.Message, enc drpc.Encoding) error {
return nil
}
func (m mockStream) MsgRecv(msg drpc.Message, enc drpc.Encoding) error {
return nil
}
func (m mockStream) CloseSend() error {
return nil
}
func (m mockStream) Close() error {
return nil
}
func (m *mockHandler) HandleRPC(stream drpc.Stream, rpc string) (err error) {
m.calls.Add(1)
return nil
}
func TestLimiter_Synchronous(t *testing.T) {
lim := New().(*limiter)
handler := &mockHandler{}
lim.cfg = Config{
DefaultTokens: Tokens{
TokensPerSecond: 100,
MaxTokens: 100,
},
ResponseTokens: map[string]Tokens{
"rpc": {
TokensPerSecond: 10,
MaxTokens: 1,
},
},
}
lim.peerCheckInterval = 10 * time.Millisecond
wrapped := lim.WrapDRPCHandler(handler)
// rpc call allows only one token max, so it should let only first call
// for second one we should wait 100 ms
firstStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer1")}
// check that we are using specific timeout
err := wrapped.HandleRPC(firstStream, "rpc")
require.NoError(t, err)
err = wrapped.HandleRPC(firstStream, "rpc")
require.Equal(t, limiterproto.ErrLimitExceeded, err)
// second stream should not affect the first one
secondStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer2")}
err = wrapped.HandleRPC(secondStream, "rpc")
require.NoError(t, err)
// after 100 ms new token has been generated
time.Sleep(100 * time.Millisecond)
err = wrapped.HandleRPC(firstStream, "rpc")
require.NoError(t, err)
time.Sleep(10 * time.Millisecond)
// checking that peer loop cleaned the map
err = lim.peerLoop(ctx)
require.NoError(t, err)
// now we should be able to call again, because we cleared the map
err = wrapped.HandleRPC(firstStream, "rpc")
require.NoError(t, err)
// but limit of 1 sec is not enough to clean the map
time.Sleep(1 * time.Millisecond)
err = wrapped.HandleRPC(firstStream, "rpc")
require.Equal(t, limiterproto.ErrLimitExceeded, err)
}
func TestLimiter_Concurrent_NoBursts(t *testing.T) {
lim := New().(*limiter)
handler := &mockHandler{}
var (
targetRps = 10
// peerRps should be greater than targetRps
peerRps = 100
reqDelay = time.Duration(1000/peerRps) * time.Millisecond
)
lim.cfg = Config{
DefaultTokens: Tokens{
TokensPerSecond: targetRps,
MaxTokens: 1,
},
}
wrapped := lim.WrapDRPCHandler(handler)
firstStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer1")}
secondStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer2")}
waitFirst := make(chan struct{})
waitSecond := make(chan struct{})
go func() {
for i := 0; i < peerRps; i++ {
time.Sleep(reqDelay)
_ = wrapped.HandleRPC(firstStream, "rpc")
}
close(waitFirst)
}()
go func() {
for i := 0; i < peerRps; i++ {
time.Sleep(reqDelay)
_ = wrapped.HandleRPC(secondStream, "rpc")
}
close(waitSecond)
}()
<-waitFirst
<-waitSecond
// 2 for number of peers and 2 for error margin (delays etc)
maxCalls := 2 * 2 * targetRps
require.Greater(t, maxCalls, int(handler.calls.Load()))
}
func TestLimiter_Concurrent_Bursts(t *testing.T) {
lim := New().(*limiter)
handler := &mockHandler{}
var (
targetRps = 10
// bursts are not affected by rps limit
burst = 10
// peerRps should be greater than targetRps + burst
peerRps = 100
reqDelay = time.Duration(1000/peerRps) * time.Millisecond
)
lim.cfg = Config{
DefaultTokens: Tokens{
TokensPerSecond: targetRps,
MaxTokens: burst,
},
}
wrapped := lim.WrapDRPCHandler(handler)
firstStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer1")}
secondStream := mockStream{ctx: peer.CtxWithPeerId(ctx, "peer2")}
waitFirst := make(chan struct{})
waitSecond := make(chan struct{})
go func() {
for i := 0; i < peerRps; i++ {
time.Sleep(reqDelay)
_ = wrapped.HandleRPC(firstStream, "rpc")
}
close(waitFirst)
}()
go func() {
for i := 0; i < peerRps; i++ {
time.Sleep(reqDelay)
_ = wrapped.HandleRPC(secondStream, "rpc")
}
close(waitSecond)
}()
<-waitFirst
<-waitSecond
// 2 for number of peers and 2 for error margin (delays etc)
maxCalls := 2 * 2 * (targetRps + burst)
minCalls := 2 * (targetRps + burst)
require.Greater(t, maxCalls, int(handler.calls.Load()))
require.LessOrEqual(t, minCalls, int(handler.calls.Load()))
}

View file

@ -0,0 +1,13 @@
package limiterproto
import (
"errors"
"github.com/anyproto/any-sync/net/rpc/rpcerr"
)
var (
errGroup = rpcerr.ErrGroup(ErrCodes_ErrorOffset)
ErrLimitExceeded = errGroup.Register(errors.New("rate limit exceeded"), uint64(ErrCodes_RateLimitExceeded))
)

View file

@ -0,0 +1,68 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: net/rpc/limiter/limiterproto/protos/limiter.proto
package limiterproto
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type ErrCodes int32
const (
ErrCodes_RateLimitExceeded ErrCodes = 0
ErrCodes_ErrorOffset ErrCodes = 700
)
var ErrCodes_name = map[int32]string{
0: "RateLimitExceeded",
700: "ErrorOffset",
}
var ErrCodes_value = map[string]int32{
"RateLimitExceeded": 0,
"ErrorOffset": 700,
}
func (x ErrCodes) String() string {
return proto.EnumName(ErrCodes_name, int32(x))
}
func (ErrCodes) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_43f29163996a95d8, []int{0}
}
func init() {
proto.RegisterEnum("limiter.ErrCodes", ErrCodes_name, ErrCodes_value)
}
func init() {
proto.RegisterFile("net/rpc/limiter/limiterproto/protos/limiter.proto", fileDescriptor_43f29163996a95d8)
}
var fileDescriptor_43f29163996a95d8 = []byte{
// 147 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xcc, 0x4b, 0x2d, 0xd1,
0x2f, 0x2a, 0x48, 0xd6, 0xcf, 0xc9, 0xcc, 0xcd, 0x2c, 0x49, 0x2d, 0x82, 0xd1, 0x05, 0x45, 0xf9,
0x25, 0xf9, 0xfa, 0x60, 0xb2, 0x18, 0x26, 0xa6, 0x07, 0xe6, 0x0a, 0xb1, 0x43, 0xb9, 0x5a, 0xc6,
0x5c, 0x1c, 0xae, 0x45, 0x45, 0xce, 0xf9, 0x29, 0xa9, 0xc5, 0x42, 0xa2, 0x5c, 0x82, 0x41, 0x89,
0x25, 0xa9, 0x3e, 0x20, 0x29, 0xd7, 0x8a, 0xe4, 0xd4, 0xd4, 0x94, 0xd4, 0x14, 0x01, 0x06, 0x21,
0x01, 0x2e, 0x6e, 0xd7, 0xa2, 0xa2, 0xfc, 0x22, 0xff, 0xb4, 0xb4, 0xe2, 0xd4, 0x12, 0x81, 0x3d,
0xac, 0x4e, 0x66, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3,
0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x25, 0x83, 0xcf,
0x29, 0x49, 0x6c, 0x60, 0xca, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x6b, 0xb3, 0x13, 0xb1,
0x00, 0x00, 0x00,
}

View file

@ -0,0 +1,8 @@
syntax = "proto3";
package limiter;
option go_package = "net/rpc/limiter/limiterproto";
enum ErrCodes {
RateLimitExceeded = 0;
ErrorOffset = 700;
}

View file

@ -0,0 +1,111 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/any-sync/net/rpc/limiter (interfaces: RpcLimiter)
//
// Generated by this command:
//
// mockgen -destination mock_limiter/mock_limiter.go github.com/anyproto/any-sync/net/rpc/limiter RpcLimiter
//
// Package mock_limiter is a generated GoMock package.
package mock_limiter
import (
context "context"
reflect "reflect"
app "github.com/anyproto/any-sync/app"
gomock "go.uber.org/mock/gomock"
drpc "storj.io/drpc"
)
// MockRpcLimiter is a mock of RpcLimiter interface.
type MockRpcLimiter struct {
ctrl *gomock.Controller
recorder *MockRpcLimiterMockRecorder
}
// MockRpcLimiterMockRecorder is the mock recorder for MockRpcLimiter.
type MockRpcLimiterMockRecorder struct {
mock *MockRpcLimiter
}
// NewMockRpcLimiter creates a new mock instance.
func NewMockRpcLimiter(ctrl *gomock.Controller) *MockRpcLimiter {
mock := &MockRpcLimiter{ctrl: ctrl}
mock.recorder = &MockRpcLimiterMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockRpcLimiter) EXPECT() *MockRpcLimiterMockRecorder {
return m.recorder
}
// Close mocks base method.
func (m *MockRpcLimiter) Close(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockRpcLimiterMockRecorder) Close(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRpcLimiter)(nil).Close), arg0)
}
// Init mocks base method.
func (m *MockRpcLimiter) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockRpcLimiterMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockRpcLimiter)(nil).Init), arg0)
}
// Name mocks base method.
func (m *MockRpcLimiter) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockRpcLimiterMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockRpcLimiter)(nil).Name))
}
// Run mocks base method.
func (m *MockRpcLimiter) Run(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Run", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Run indicates an expected call of Run.
func (mr *MockRpcLimiterMockRecorder) Run(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockRpcLimiter)(nil).Run), arg0)
}
// WrapDRPCHandler mocks base method.
func (m *MockRpcLimiter) WrapDRPCHandler(arg0 drpc.Handler) drpc.Handler {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "WrapDRPCHandler", arg0)
ret0, _ := ret[0].(drpc.Handler)
return ret0
}
// WrapDRPCHandler indicates an expected call of WrapDRPCHandler.
func (mr *MockRpcLimiterMockRecorder) WrapDRPCHandler(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WrapDRPCHandler", reflect.TypeOf((*MockRpcLimiter)(nil).WrapDRPCHandler), arg0)
}

View file

@ -43,7 +43,7 @@ func Unwrap(e error) error {
} }
err, ok := errsMap[code] err, ok := errsMap[code]
if !ok { if !ok {
return drpcerr.WithCode(fmt.Errorf("unexpected error: %v; code: %d", err, code), code) return drpcerr.WithCode(fmt.Errorf("unexpected error: %w; code: %d", e, code), code)
} }
return err return err
} }

View file

@ -2,12 +2,15 @@ package server
import ( import (
"context" "context"
"net"
"github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/metric" "github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/net/rpc" "github.com/anyproto/any-sync/net/rpc"
"github.com/anyproto/any-sync/net/rpc/limiter"
"go.uber.org/zap" "go.uber.org/zap"
"net"
"storj.io/drpc" "storj.io/drpc"
"storj.io/drpc/drpcmanager" "storj.io/drpc/drpcmanager"
"storj.io/drpc/drpcmux" "storj.io/drpc/drpcmux"
@ -34,8 +37,9 @@ type DRPCServer interface {
type drpcServer struct { type drpcServer struct {
drpcServer *drpcserver.Server drpcServer *drpcserver.Server
*drpcmux.Mux *drpcmux.Mux
config rpc.Config config rpc.Config
metric metric.Metric metric metric.Metric
limiter limiter.RpcLimiter
} }
type DRPCHandlerWrapper func(handler drpc.Handler) drpc.Handler type DRPCHandlerWrapper func(handler drpc.Handler) drpc.Handler
@ -47,12 +51,16 @@ func (s *drpcServer) Name() (name string) {
func (s *drpcServer) Init(a *app.App) (err error) { func (s *drpcServer) Init(a *app.App) (err error) {
s.config = a.MustComponent("config").(rpc.ConfigGetter).GetDrpc() s.config = a.MustComponent("config").(rpc.ConfigGetter).GetDrpc()
s.metric, _ = a.Component(metric.CName).(metric.Metric) s.metric, _ = a.Component(metric.CName).(metric.Metric)
s.limiter, _ = a.Component(limiter.CName).(limiter.RpcLimiter)
s.Mux = drpcmux.New() s.Mux = drpcmux.New()
var handler drpc.Handler var handler drpc.Handler
handler = s handler = s
if s.limiter != nil {
handler = s.limiter.WrapDRPCHandler(handler)
}
if s.metric != nil { if s.metric != nil {
handler = s.metric.WrapDRPCHandler(s) handler = s.metric.WrapDRPCHandler(handler)
} }
bufSize := s.config.Stream.MaxMsgSizeMb * (1 << 20) bufSize := s.config.Stream.MaxMsgSizeMb * (1 << 20)
s.drpcServer = drpcserver.NewWithOptions(handler, drpcserver.Options{Manager: drpcmanager.Options{ s.drpcServer = drpcserver.NewWithOptions(handler, drpcserver.Options{Manager: drpcmanager.Options{

View file

@ -0,0 +1,99 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/anyproto/any-sync/node/nodeclient (interfaces: NodeClient)
//
// Generated by this command:
//
// mockgen -destination mock_nodeclient/mock_nodeclient.go github.com/anyproto/any-sync/node/nodeclient NodeClient
//
// Package mock_nodeclient is a generated GoMock package.
package mock_nodeclient
import (
context "context"
reflect "reflect"
app "github.com/anyproto/any-sync/app"
consensusproto "github.com/anyproto/any-sync/consensus/consensusproto"
gomock "go.uber.org/mock/gomock"
)
// MockNodeClient is a mock of NodeClient interface.
type MockNodeClient struct {
ctrl *gomock.Controller
recorder *MockNodeClientMockRecorder
}
// MockNodeClientMockRecorder is the mock recorder for MockNodeClient.
type MockNodeClientMockRecorder struct {
mock *MockNodeClient
}
// NewMockNodeClient creates a new mock instance.
func NewMockNodeClient(ctrl *gomock.Controller) *MockNodeClient {
mock := &MockNodeClient{ctrl: ctrl}
mock.recorder = &MockNodeClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockNodeClient) EXPECT() *MockNodeClientMockRecorder {
return m.recorder
}
// AclAddRecord mocks base method.
func (m *MockNodeClient) AclAddRecord(arg0 context.Context, arg1 string, arg2 *consensusproto.RawRecord) (*consensusproto.RawRecordWithId, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AclAddRecord", arg0, arg1, arg2)
ret0, _ := ret[0].(*consensusproto.RawRecordWithId)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AclAddRecord indicates an expected call of AclAddRecord.
func (mr *MockNodeClientMockRecorder) AclAddRecord(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AclAddRecord", reflect.TypeOf((*MockNodeClient)(nil).AclAddRecord), arg0, arg1, arg2)
}
// AclGetRecords mocks base method.
func (m *MockNodeClient) AclGetRecords(arg0 context.Context, arg1, arg2 string) ([]*consensusproto.RawRecordWithId, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AclGetRecords", arg0, arg1, arg2)
ret0, _ := ret[0].([]*consensusproto.RawRecordWithId)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AclGetRecords indicates an expected call of AclGetRecords.
func (mr *MockNodeClientMockRecorder) AclGetRecords(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AclGetRecords", reflect.TypeOf((*MockNodeClient)(nil).AclGetRecords), arg0, arg1, arg2)
}
// Init mocks base method.
func (m *MockNodeClient) Init(arg0 *app.App) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Init", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Init indicates an expected call of Init.
func (mr *MockNodeClientMockRecorder) Init(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockNodeClient)(nil).Init), arg0)
}
// Name mocks base method.
func (m *MockNodeClient) Name() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Name")
ret0, _ := ret[0].(string)
return ret0
}
// Name indicates an expected call of Name.
func (mr *MockNodeClientMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockNodeClient)(nil).Name))
}

View file

@ -0,0 +1,98 @@
//go:generate mockgen -destination mock_nodeclient/mock_nodeclient.go github.com/anyproto/any-sync/node/nodeclient NodeClient
package nodeclient
import (
"context"
"storj.io/drpc"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
"github.com/anyproto/any-sync/consensus/consensusproto"
"github.com/anyproto/any-sync/net/pool"
"github.com/anyproto/any-sync/net/rpc/rpcerr"
"github.com/anyproto/any-sync/nodeconf"
)
const CName = "common.node.nodeclient"
func New() NodeClient {
return &nodeClient{}
}
type NodeClient interface {
app.Component
AclGetRecords(ctx context.Context, spaceId, aclHead string) (recs []*consensusproto.RawRecordWithId, err error)
AclAddRecord(ctx context.Context, spaceId string, rec *consensusproto.RawRecord) (recWithId *consensusproto.RawRecordWithId, err error)
}
type nodeClient struct {
pool pool.Service
nodeConf nodeconf.Service
}
func (c *nodeClient) Init(a *app.App) (err error) {
c.pool = a.MustComponent(pool.CName).(pool.Service)
c.nodeConf = a.MustComponent(nodeconf.CName).(nodeconf.Service)
return
}
func (c *nodeClient) Name() (name string) {
return CName
}
func (c *nodeClient) AclGetRecords(ctx context.Context, spaceId, aclHead string) (recs []*consensusproto.RawRecordWithId, err error) {
err = clientDo(c, ctx, spaceId, func(cl spacesyncproto.DRPCSpaceSyncClient) error {
resp, err := cl.AclGetRecords(ctx, &spacesyncproto.AclGetRecordsRequest{
SpaceId: spaceId,
AclHead: aclHead,
})
if err != nil {
return err
}
recs = make([]*consensusproto.RawRecordWithId, len(resp.Records))
for i, rec := range resp.Records {
recs[i] = &consensusproto.RawRecordWithId{}
if err = recs[i].Unmarshal(rec); err != nil {
return err
}
}
return nil
})
return
}
func (c *nodeClient) AclAddRecord(ctx context.Context, spaceId string, rec *consensusproto.RawRecord) (recWithId *consensusproto.RawRecordWithId, err error) {
data, err := rec.Marshal()
if err != nil {
return
}
err = clientDo(c, ctx, spaceId, func(cl spacesyncproto.DRPCSpaceSyncClient) error {
res, err := cl.AclAddRecord(ctx, &spacesyncproto.AclAddRecordRequest{
SpaceId: spaceId,
Payload: data,
})
if err != nil {
return err
}
recWithId = &consensusproto.RawRecordWithId{
Payload: res.Payload,
Id: res.RecordId,
}
return nil
})
return
}
var clientDo = (*nodeClient).doClient
func (c *nodeClient) doClient(ctx context.Context, spaceId string, f func(cl spacesyncproto.DRPCSpaceSyncClient) error) error {
p, err := c.pool.GetOneOf(ctx, c.nodeConf.NodeIds(spaceId))
if err != nil {
return err
}
return p.DoDrpc(ctx, func(conn drpc.Conn) error {
err := f(spacesyncproto.NewDRPCSpaceSyncClient(conn))
return rpcerr.Unwrap(err)
})
}

View file

@ -0,0 +1,92 @@
package nodeclient
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
"github.com/anyproto/any-sync/commonspace/spacesyncproto/mock_spacesyncproto"
"github.com/anyproto/any-sync/consensus/consensusproto"
)
var ctx = context.Background()
type fixture struct {
*nodeClient
ctrl *gomock.Controller
}
func (f *fixture) finish() {
f.ctrl.Finish()
}
func newFixture(t *testing.T) *fixture {
ctrl := gomock.NewController(t)
return &fixture{
nodeClient: New().(*nodeClient),
ctrl: ctrl,
}
}
func TestNodeClient_AclGetRecords(t *testing.T) {
f := newFixture(t)
defer f.finish()
spaceId := "spaceId"
aclHead := "aclHead"
cl := mock_spacesyncproto.NewMockDRPCSpaceSyncClient(f.ctrl)
clientDo = func(client *nodeClient, ctx context.Context, s string, f func(cl spacesyncproto.DRPCSpaceSyncClient) error) error {
return f(cl)
}
var (
expectedRecs []*consensusproto.RawRecordWithId
expectedByteRecs [][]byte
total = 5
)
for i := 0; i < total; i++ {
expectedRecs = append(expectedRecs, &consensusproto.RawRecordWithId{
Id: fmt.Sprint(i),
})
marshalled, err := expectedRecs[i].Marshal()
require.NoError(t, err)
expectedByteRecs = append(expectedByteRecs, marshalled)
}
cl.EXPECT().AclGetRecords(ctx, &spacesyncproto.AclGetRecordsRequest{
SpaceId: spaceId,
AclHead: aclHead,
}).Return(&spacesyncproto.AclGetRecordsResponse{Records: expectedByteRecs}, nil)
recs, err := f.AclGetRecords(ctx, spaceId, aclHead)
require.NoError(t, err)
require.Equal(t, expectedRecs, recs)
}
func TestNodeClient_AclAddRecords(t *testing.T) {
f := newFixture(t)
defer f.finish()
spaceId := "spaceId"
cl := mock_spacesyncproto.NewMockDRPCSpaceSyncClient(f.ctrl)
clientDo = func(client *nodeClient, ctx context.Context, s string, f func(cl spacesyncproto.DRPCSpaceSyncClient) error) error {
return f(cl)
}
sendRec := &consensusproto.RawRecord{
AcceptorTimestamp: 10,
}
data, err := sendRec.Marshal()
require.NoError(t, err)
expectedRec := &consensusproto.RawRecordWithId{
Id: "recId",
Payload: data,
}
cl.EXPECT().AclAddRecord(ctx, &spacesyncproto.AclAddRecordRequest{
SpaceId: spaceId,
Payload: data,
}).Return(&spacesyncproto.AclAddRecordResponse{RecordId: expectedRec.Id, Payload: expectedRec.Payload}, nil)
rec, err := f.AclAddRecord(ctx, spaceId, sendRec)
require.NoError(t, err)
require.Equal(t, expectedRec, rec)
}

View file

@ -0,0 +1,29 @@
package paymentserviceproto
import (
"errors"
"github.com/anyproto/any-sync/net/rpc/rpcerr"
)
var (
errGroup = rpcerr.ErrGroup(ErrorCodes_ErrorOffset)
ErrEthAddressEmpty = errGroup.Register(errors.New("owner eth address is empty"), uint64(ErrorCodes_EthAddressEmpty))
ErrInvalidSignature = errGroup.Register(errors.New("invalid signature"), uint64(ErrorCodes_InvalidSignature))
ErrTierWrong = errGroup.Register(errors.New("wrong tier specified"), uint64(ErrorCodes_TierWrong))
ErrTierNotFound = errGroup.Register(errors.New("requested tier not found"), uint64(ErrorCodes_TierNotFound))
ErrTierInactive = errGroup.Register(errors.New("requested tier is not active"), uint64(ErrorCodes_TierInactive))
ErrPaymentMethodWrong = errGroup.Register(errors.New("wrong payment method specified"), uint64(ErrorCodes_PaymentMethodWrong))
ErrBadAnyName = errGroup.Register(errors.New("bad any name specified"), uint64(ErrorCodes_BadAnyName))
ErrUnknown = errGroup.Register(errors.New("unknown error"), uint64(ErrorCodes_Unknown))
ErrSubsAlreadyActive = errGroup.Register(errors.New("user already has an active subscription"), uint64(ErrorCodes_SubsAlreadyActive))
ErrSubsNotFound = errGroup.Register(errors.New("no subscription for user"), uint64(ErrorCodes_SubsNotFound))
ErrSubsWrongState = errGroup.Register(errors.New("subscription is not in PendingRequiresFinalization state"), uint64(ErrorCodes_SubsWrongState))
ErrEmailWrongFormat = errGroup.Register(errors.New("wrong email format"), uint64(ErrorCodes_EmailWrongFormat))
ErrEmailAlreadyVerified = errGroup.Register(errors.New("email already verified"), uint64(ErrorCodes_EmailAlreadyVerified))
ErrEmailAlreadySent = errGroup.Register(errors.New("email verification request already sent. wait for the email or try again later"), uint64(ErrorCodes_EmailAlreadySent))
ErrEmailFailedToSend = errGroup.Register(errors.New("failed to send email"), uint64(ErrorCodes_EmailFailedToSend))
ErrEmailExpired = errGroup.Register(errors.New("email verification request expired. try getting new code"), uint64(ErrorCodes_EmailExpired))
ErrEmailWrongCode = errGroup.Register(errors.New("wrong verification code"), uint64(ErrorCodes_EmailWrongCode))
)

View file

@ -146,6 +146,82 @@ func (PaymentMethod) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_4feb29dcc5ba50f6, []int{2} return fileDescriptor_4feb29dcc5ba50f6, []int{2}
} }
type ErrorCodes int32
const (
ErrorCodes_Unexpected ErrorCodes = 0
ErrorCodes_EthAddressEmpty ErrorCodes = 1
ErrorCodes_InvalidSignature ErrorCodes = 2
ErrorCodes_TierWrong ErrorCodes = 3
ErrorCodes_TierNotFound ErrorCodes = 4
ErrorCodes_TierInactive ErrorCodes = 5
ErrorCodes_PaymentMethodWrong ErrorCodes = 6
ErrorCodes_BadAnyName ErrorCodes = 7
ErrorCodes_Unknown ErrorCodes = 8
ErrorCodes_SubsAlreadyActive ErrorCodes = 9
ErrorCodes_SubsNotFound ErrorCodes = 10
ErrorCodes_SubsWrongState ErrorCodes = 11
ErrorCodes_EmailWrongFormat ErrorCodes = 12
ErrorCodes_EmailAlreadyVerified ErrorCodes = 13
ErrorCodes_EmailAlreadySent ErrorCodes = 14
ErrorCodes_EmailFailedToSend ErrorCodes = 15
ErrorCodes_EmailExpired ErrorCodes = 16
ErrorCodes_EmailWrongCode ErrorCodes = 17
ErrorCodes_ErrorOffset ErrorCodes = 600
)
var ErrorCodes_name = map[int32]string{
0: "Unexpected",
1: "EthAddressEmpty",
2: "InvalidSignature",
3: "TierWrong",
4: "TierNotFound",
5: "TierInactive",
6: "PaymentMethodWrong",
7: "BadAnyName",
8: "Unknown",
9: "SubsAlreadyActive",
10: "SubsNotFound",
11: "SubsWrongState",
12: "EmailWrongFormat",
13: "EmailAlreadyVerified",
14: "EmailAlreadySent",
15: "EmailFailedToSend",
16: "EmailExpired",
17: "EmailWrongCode",
600: "ErrorOffset",
}
var ErrorCodes_value = map[string]int32{
"Unexpected": 0,
"EthAddressEmpty": 1,
"InvalidSignature": 2,
"TierWrong": 3,
"TierNotFound": 4,
"TierInactive": 5,
"PaymentMethodWrong": 6,
"BadAnyName": 7,
"Unknown": 8,
"SubsAlreadyActive": 9,
"SubsNotFound": 10,
"SubsWrongState": 11,
"EmailWrongFormat": 12,
"EmailAlreadyVerified": 13,
"EmailAlreadySent": 14,
"EmailFailedToSend": 15,
"EmailExpired": 16,
"EmailWrongCode": 17,
"ErrorOffset": 600,
}
func (x ErrorCodes) String() string {
return proto.EnumName(ErrorCodes_name, int32(x))
}
func (ErrorCodes) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_4feb29dcc5ba50f6, []int{3}
}
type IsNameValidResponse_Code int32 type IsNameValidResponse_Code int32
const ( const (
@ -284,8 +360,8 @@ func (m *GetSubscriptionRequestSigned) GetSignature() []byte {
} }
type GetSubscriptionResponse struct { type GetSubscriptionResponse struct {
// was SubscriptionTier before, changed to int32 to allow us to use dynamic tiers // was SubscriptionTier before, changed to uint32 to allow us to use dynamic tiers
Tier int32 `protobuf:"varint,1,opt,name=tier,proto3" json:"tier,omitempty"` Tier uint32 `protobuf:"varint,1,opt,name=tier,proto3" json:"tier,omitempty"`
Status SubscriptionStatus `protobuf:"varint,2,opt,name=status,proto3,enum=SubscriptionStatus" json:"status,omitempty"` Status SubscriptionStatus `protobuf:"varint,2,opt,name=status,proto3,enum=SubscriptionStatus" json:"status,omitempty"`
DateStarted uint64 `protobuf:"varint,3,opt,name=dateStarted,proto3" json:"dateStarted,omitempty"` DateStarted uint64 `protobuf:"varint,3,opt,name=dateStarted,proto3" json:"dateStarted,omitempty"`
DateEnds uint64 `protobuf:"varint,4,opt,name=dateEnds,proto3" json:"dateEnds,omitempty"` DateEnds uint64 `protobuf:"varint,4,opt,name=dateEnds,proto3" json:"dateEnds,omitempty"`
@ -330,7 +406,7 @@ func (m *GetSubscriptionResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_GetSubscriptionResponse proto.InternalMessageInfo var xxx_messageInfo_GetSubscriptionResponse proto.InternalMessageInfo
func (m *GetSubscriptionResponse) GetTier() int32 { func (m *GetSubscriptionResponse) GetTier() uint32 {
if m != nil { if m != nil {
return m.Tier return m.Tier
} }
@ -402,8 +478,8 @@ type BuySubscriptionRequest struct {
// this is required to reserve a name for the owner (later that is done by user) // this is required to reserve a name for the owner (later that is done by user)
// in the following format: "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" // in the following format: "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"
OwnerEthAddress string `protobuf:"bytes,2,opt,name=ownerEthAddress,proto3" json:"ownerEthAddress,omitempty"` OwnerEthAddress string `protobuf:"bytes,2,opt,name=ownerEthAddress,proto3" json:"ownerEthAddress,omitempty"`
// was SubscriptionTier before, changed to int32 to allow us to use dynamic tiers // was SubscriptionTier before, changed to uint32 to allow us to use dynamic tiers
RequestedTier int32 `protobuf:"varint,3,opt,name=requestedTier,proto3" json:"requestedTier,omitempty"` RequestedTier uint32 `protobuf:"varint,3,opt,name=requestedTier,proto3" json:"requestedTier,omitempty"`
PaymentMethod PaymentMethod `protobuf:"varint,4,opt,name=paymentMethod,proto3,enum=PaymentMethod" json:"paymentMethod,omitempty"` PaymentMethod PaymentMethod `protobuf:"varint,4,opt,name=paymentMethod,proto3,enum=PaymentMethod" json:"paymentMethod,omitempty"`
// if empty - then no name requested // if empty - then no name requested
// if non-empty - PP node will register that name on behalf of the user // if non-empty - PP node will register that name on behalf of the user
@ -457,7 +533,7 @@ func (m *BuySubscriptionRequest) GetOwnerEthAddress() string {
return "" return ""
} }
func (m *BuySubscriptionRequest) GetRequestedTier() int32 { func (m *BuySubscriptionRequest) GetRequestedTier() uint32 {
if m != nil { if m != nil {
return m.RequestedTier return m.RequestedTier
} }
@ -536,6 +612,8 @@ type BuySubscriptionResponse struct {
// will feature current billing ID // will feature current billing ID
// stripe.com/?client_reference_id=1234 // stripe.com/?client_reference_id=1234
PaymentUrl string `protobuf:"bytes,1,opt,name=paymentUrl,proto3" json:"paymentUrl,omitempty"` PaymentUrl string `protobuf:"bytes,1,opt,name=paymentUrl,proto3" json:"paymentUrl,omitempty"`
// billingID is passed via mobile client to payment platform
BillingID string `protobuf:"bytes,2,opt,name=billingID,proto3" json:"billingID,omitempty"`
} }
func (m *BuySubscriptionResponse) Reset() { *m = BuySubscriptionResponse{} } func (m *BuySubscriptionResponse) Reset() { *m = BuySubscriptionResponse{} }
@ -578,6 +656,13 @@ func (m *BuySubscriptionResponse) GetPaymentUrl() string {
return "" return ""
} }
func (m *BuySubscriptionResponse) GetBillingID() string {
if m != nil {
return m.BillingID
}
return ""
}
type FinalizeSubscriptionRequest struct { type FinalizeSubscriptionRequest struct {
// in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65" // in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65"
// you can get it with Account().SignKey.GetPublic().Account() // you can get it with Account().SignKey.GetPublic().Account()
@ -1199,7 +1284,7 @@ func (m *VerifyEmailRequestSigned) GetSignature() []byte {
} }
type IsNameValidRequest struct { type IsNameValidRequest struct {
RequestedTier int32 `protobuf:"varint,1,opt,name=requestedTier,proto3" json:"requestedTier,omitempty"` RequestedTier uint32 `protobuf:"varint,1,opt,name=requestedTier,proto3" json:"requestedTier,omitempty"`
RequestedAnyName string `protobuf:"bytes,2,opt,name=requestedAnyName,proto3" json:"requestedAnyName,omitempty"` RequestedAnyName string `protobuf:"bytes,2,opt,name=requestedAnyName,proto3" json:"requestedAnyName,omitempty"`
} }
@ -1236,7 +1321,7 @@ func (m *IsNameValidRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_IsNameValidRequest proto.InternalMessageInfo var xxx_messageInfo_IsNameValidRequest proto.InternalMessageInfo
func (m *IsNameValidRequest) GetRequestedTier() int32 { func (m *IsNameValidRequest) GetRequestedTier() uint32 {
if m != nil { if m != nil {
return m.RequestedTier return m.RequestedTier
} }
@ -1306,6 +1391,7 @@ func init() {
proto.RegisterEnum("SubscriptionTier", SubscriptionTier_name, SubscriptionTier_value) proto.RegisterEnum("SubscriptionTier", SubscriptionTier_name, SubscriptionTier_value)
proto.RegisterEnum("SubscriptionStatus", SubscriptionStatus_name, SubscriptionStatus_value) proto.RegisterEnum("SubscriptionStatus", SubscriptionStatus_name, SubscriptionStatus_value)
proto.RegisterEnum("PaymentMethod", PaymentMethod_name, PaymentMethod_value) proto.RegisterEnum("PaymentMethod", PaymentMethod_name, PaymentMethod_value)
proto.RegisterEnum("ErrorCodes", ErrorCodes_name, ErrorCodes_value)
proto.RegisterEnum("IsNameValidResponse_Code", IsNameValidResponse_Code_name, IsNameValidResponse_Code_value) proto.RegisterEnum("IsNameValidResponse_Code", IsNameValidResponse_Code_name, IsNameValidResponse_Code_value)
proto.RegisterType((*GetSubscriptionRequest)(nil), "GetSubscriptionRequest") proto.RegisterType((*GetSubscriptionRequest)(nil), "GetSubscriptionRequest")
proto.RegisterType((*GetSubscriptionRequestSigned)(nil), "GetSubscriptionRequestSigned") proto.RegisterType((*GetSubscriptionRequestSigned)(nil), "GetSubscriptionRequestSigned")
@ -1334,80 +1420,93 @@ func init() {
} }
var fileDescriptor_4feb29dcc5ba50f6 = []byte{ var fileDescriptor_4feb29dcc5ba50f6 = []byte{
// 1157 bytes of a gzipped FileDescriptorProto // 1363 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6f, 0x1b, 0x45,
0x14, 0xf7, 0xfa, 0x4f, 0x12, 0xbf, 0x34, 0xc9, 0xf6, 0xc5, 0x4d, 0xb7, 0x6e, 0x62, 0xa5, 0x2b, 0x14, 0xf7, 0xfa, 0x23, 0x89, 0x9f, 0xe3, 0x64, 0x32, 0x71, 0xd3, 0xad, 0x9b, 0x58, 0xe9, 0x8a,
0xfe, 0x44, 0x41, 0x6c, 0x45, 0xe9, 0x01, 0x10, 0x42, 0x38, 0x69, 0x1a, 0x22, 0x95, 0xc8, 0x5a, 0x8f, 0x28, 0x88, 0xad, 0x28, 0x3d, 0x20, 0x84, 0x10, 0x4e, 0xe2, 0x84, 0x48, 0x25, 0x44, 0xb6,
0xbb, 0x45, 0xd0, 0x03, 0x6c, 0xbd, 0x53, 0x67, 0xc9, 0x66, 0x66, 0x99, 0x19, 0x27, 0x2c, 0x5f, 0xdb, 0x0a, 0x7a, 0x80, 0x8d, 0xf7, 0xc5, 0x59, 0xba, 0x99, 0x59, 0x66, 0xc7, 0x4d, 0xcd, 0x8d,
0x00, 0x71, 0x43, 0xe2, 0xc2, 0xf7, 0xe1, 0xc2, 0x09, 0xf5, 0xc8, 0x11, 0x25, 0x37, 0x4e, 0x7c, 0x13, 0xe2, 0x86, 0xc4, 0x85, 0xff, 0x87, 0x0b, 0x27, 0xd4, 0x63, 0x8f, 0xa8, 0xbd, 0x71, 0xe2,
0x04, 0x34, 0xb3, 0xeb, 0x78, 0x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a1, 0x96, 0x7d,
0xe9, 0x5c, 0x53, 0x5d, 0xb3, 0xa7, 0xce, 0x46, 0x19, 0xfa, 0x1d, 0xdc, 0x9a, 0x38, 0x1a, 0xd0,
0x77, 0xed, 0xab, 0x0d, 0x26, 0x55, 0xcb, 0xbe, 0x74, 0xbe, 0x88, 0x1c, 0x49, 0x7b, 0x97, 0xa9,
0x96, 0x9e, 0xfe, 0x5c, 0x57, 0xd7, 0xec, 0xa9, 0x4f, 0x7e, 0x86, 0x7e, 0x06, 0xa5, 0xc4, 0x93,
0x47, 0x6f, 0xd9, 0x93, 0x1e, 0xc0, 0x6a, 0xc5, 0x4e, 0x79, 0x4c, 0xa3, 0x88, 0xef, 0xa1, 0xac,
0xfb, 0xbe, 0xaa, 0xbe, 0x90, 0xae, 0xa8, 0x1b, 0xf5, 0xe7, 0xa8, 0xf8, 0x52, 0x02, 0x1f, 0xc8,
0x6e, 0x7d, 0xf2, 0xc7, 0xab, 0x9a, 0xf1, 0xe2, 0x55, 0xcd, 0xf8, 0xeb, 0x55, 0xcd, 0xf8, 0xe5,
0x75, 0x2d, 0xf3, 0xe2, 0x75, 0x2d, 0xf3, 0xf2, 0x75, 0x2d, 0xf3, 0xb5, 0x75, 0xf9, 0xaf, 0xe3,
0xa3, 0x19, 0xfd, 0xef, 0xc3, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x38, 0x9b, 0x47, 0x11, 0x8a,
0x0f, 0x00, 0x00,
} }
func (m *GetSubscriptionRequest) Marshal() (dAtA []byte, err error) { func (m *GetSubscriptionRequest) Marshal() (dAtA []byte, err error) {
@ -1670,6 +1769,13 @@ func (m *BuySubscriptionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.BillingID) > 0 {
i -= len(m.BillingID)
copy(dAtA[i:], m.BillingID)
i = encodeVarintPaymentservice(dAtA, i, uint64(len(m.BillingID)))
i--
dAtA[i] = 0x12
}
if len(m.PaymentUrl) > 0 { if len(m.PaymentUrl) > 0 {
i -= len(m.PaymentUrl) i -= len(m.PaymentUrl)
copy(dAtA[i:], m.PaymentUrl) copy(dAtA[i:], m.PaymentUrl)
@ -2305,6 +2411,10 @@ func (m *BuySubscriptionResponse) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovPaymentservice(uint64(l)) n += 1 + l + sovPaymentservice(uint64(l))
} }
l = len(m.BillingID)
if l > 0 {
n += 1 + l + sovPaymentservice(uint64(l))
}
return n return n
} }
@ -2775,7 +2885,7 @@ func (m *GetSubscriptionResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Tier |= int32(b&0x7F) << shift m.Tier |= uint32(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -3088,7 +3198,7 @@ func (m *BuySubscriptionRequest) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.RequestedTier |= int32(b&0x7F) << shift m.RequestedTier |= uint32(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -3344,6 +3454,38 @@ func (m *BuySubscriptionResponse) Unmarshal(dAtA []byte) error {
} }
m.PaymentUrl = string(dAtA[iNdEx:postIndex]) m.PaymentUrl = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BillingID", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPaymentservice
}
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 ErrInvalidLengthPaymentservice
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthPaymentservice
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.BillingID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipPaymentservice(dAtA[iNdEx:]) skippy, err := skipPaymentservice(dAtA[iNdEx:])
@ -4640,7 +4782,7 @@ func (m *IsNameValidRequest) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.RequestedTier |= int32(b&0x7F) << shift m.RequestedTier |= uint32(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }

View file

@ -60,13 +60,7 @@ func (PeriodType) EnumDescriptor() ([]byte, []int) {
} }
type Feature struct { type Feature struct {
// "invites" Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
// "GBs"
// "spaces"
// ...
ValueStr string `protobuf:"bytes,1,opt,name=valueStr,proto3" json:"valueStr,omitempty"`
// each uint is a value of the feature
ValueUint uint32 `protobuf:"varint,2,opt,name=valueUint,proto3" json:"valueUint,omitempty"`
} }
func (m *Feature) Reset() { *m = Feature{} } func (m *Feature) Reset() { *m = Feature{} }
@ -102,27 +96,18 @@ func (m *Feature) XXX_DiscardUnknown() {
var xxx_messageInfo_Feature proto.InternalMessageInfo var xxx_messageInfo_Feature proto.InternalMessageInfo
func (m *Feature) GetValueStr() string { func (m *Feature) GetDescription() string {
if m != nil { if m != nil {
return m.ValueStr return m.Description
} }
return "" return ""
} }
func (m *Feature) GetValueUint() uint32 {
if m != nil {
return m.ValueUint
}
return 0
}
type GetTiersRequest struct { type GetTiersRequest struct {
// in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65" // in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65"
// you can get it with Account().SignKey.GetPublic().Account() // you can get it with Account().SignKey.GetPublic().Account()
OwnerAnyId string `protobuf:"bytes,1,opt,name=ownerAnyId,proto3" json:"ownerAnyId,omitempty"` OwnerAnyId string `protobuf:"bytes,1,opt,name=ownerAnyId,proto3" json:"ownerAnyId,omitempty"`
Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"` Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"`
// see PaymentMethod enum
PaymentMethod uint32 `protobuf:"varint,3,opt,name=paymentMethod,proto3" json:"paymentMethod,omitempty"`
} }
func (m *GetTiersRequest) Reset() { *m = GetTiersRequest{} } func (m *GetTiersRequest) Reset() { *m = GetTiersRequest{} }
@ -172,13 +157,6 @@ func (m *GetTiersRequest) GetLocale() string {
return "" return ""
} }
func (m *GetTiersRequest) GetPaymentMethod() uint32 {
if m != nil {
return m.PaymentMethod
}
return 0
}
type GetTiersRequestSigned struct { type GetTiersRequestSigned struct {
// GetTiersRequest struct // GetTiersRequest struct
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
@ -261,9 +239,9 @@ type TierData struct {
// somename.any - len of 8 // somename.any - len of 8
AnyNameMinLength uint32 `protobuf:"varint,11,opt,name=anyNameMinLength,proto3" json:"anyNameMinLength,omitempty"` AnyNameMinLength uint32 `protobuf:"varint,11,opt,name=anyNameMinLength,proto3" json:"anyNameMinLength,omitempty"`
// each tier has a set of features // each tier has a set of features
// each feature has a unique key: "storage", "invites", etc Features []*Feature `protobuf:"bytes,12,rep,name=features,proto3" json:"features,omitempty"`
// not using enum here to provide dynamic feature list // green, blue, red, purple or custom color in string format #ff00ff
Features map[string]*Feature `protobuf:"bytes,12,rep,name=features,proto3" json:"features,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` ColorStr string `protobuf:"bytes,13,opt,name=colorStr,proto3" json:"colorStr,omitempty"`
} }
func (m *TierData) Reset() { *m = TierData{} } func (m *TierData) Reset() { *m = TierData{} }
@ -376,13 +354,20 @@ func (m *TierData) GetAnyNameMinLength() uint32 {
return 0 return 0
} }
func (m *TierData) GetFeatures() map[string]*Feature { func (m *TierData) GetFeatures() []*Feature {
if m != nil { if m != nil {
return m.Features return m.Features
} }
return nil return nil
} }
func (m *TierData) GetColorStr() string {
if m != nil {
return m.ColorStr
}
return ""
}
type GetTiersResponse struct { type GetTiersResponse struct {
// list of all available tiers // list of all available tiers
Tiers []*TierData `protobuf:"bytes,1,rep,name=tiers,proto3" json:"tiers,omitempty"` Tiers []*TierData `protobuf:"bytes,1,rep,name=tiers,proto3" json:"tiers,omitempty"`
@ -434,7 +419,6 @@ func init() {
proto.RegisterType((*GetTiersRequest)(nil), "GetTiersRequest") proto.RegisterType((*GetTiersRequest)(nil), "GetTiersRequest")
proto.RegisterType((*GetTiersRequestSigned)(nil), "GetTiersRequestSigned") proto.RegisterType((*GetTiersRequestSigned)(nil), "GetTiersRequestSigned")
proto.RegisterType((*TierData)(nil), "TierData") proto.RegisterType((*TierData)(nil), "TierData")
proto.RegisterMapType((map[string]*Feature)(nil), "TierData.FeaturesEntry")
proto.RegisterType((*GetTiersResponse)(nil), "GetTiersResponse") proto.RegisterType((*GetTiersResponse)(nil), "GetTiersResponse")
} }
@ -443,46 +427,42 @@ func init() {
} }
var fileDescriptor_597ac3048c641f44 = []byte{ var fileDescriptor_597ac3048c641f44 = []byte{
// 615 bytes of a gzipped FileDescriptorProto // 549 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xcf, 0x4f, 0xdb, 0x4a, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x4d, 0x6f, 0xd3, 0x4c,
0x10, 0xc7, 0xe3, 0xfc, 0x80, 0x64, 0x92, 0x80, 0xdf, 0xf0, 0x78, 0xac, 0xd0, 0x93, 0x5f, 0x64, 0x10, 0xc7, 0xe3, 0xa4, 0x2f, 0x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0xee, 0x4f, 0x49, 0x65, 0x04, 0x00, 0x00,
} }
func (m *Feature) Marshal() (dAtA []byte, err error) { func (m *Feature) Marshal() (dAtA []byte, err error) {
@ -505,15 +485,10 @@ func (m *Feature) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if m.ValueUint != 0 { if len(m.Description) > 0 {
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(m.ValueUint)) i -= len(m.Description)
i-- copy(dAtA[i:], m.Description)
dAtA[i] = 0x10 i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(len(m.Description)))
}
if len(m.ValueStr) > 0 {
i -= len(m.ValueStr)
copy(dAtA[i:], m.ValueStr)
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(len(m.ValueStr)))
i-- i--
dAtA[i] = 0xa dAtA[i] = 0xa
} }
@ -540,11 +515,6 @@ func (m *GetTiersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if m.PaymentMethod != 0 {
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(m.PaymentMethod))
i--
dAtA[i] = 0x18
}
if len(m.Locale) > 0 { if len(m.Locale) > 0 {
i -= len(m.Locale) i -= len(m.Locale)
copy(dAtA[i:], m.Locale) copy(dAtA[i:], m.Locale)
@ -619,28 +589,23 @@ func (m *TierData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.ColorStr) > 0 {
i -= len(m.ColorStr)
copy(dAtA[i:], m.ColorStr)
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(len(m.ColorStr)))
i--
dAtA[i] = 0x6a
}
if len(m.Features) > 0 { if len(m.Features) > 0 {
for k := range m.Features { for iNdEx := len(m.Features) - 1; iNdEx >= 0; iNdEx-- {
v := m.Features[k] {
baseI := i size, err := m.Features[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if v != nil { if err != nil {
{ return 0, err
size, err := v.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(size))
} }
i-- i -= size
dAtA[i] = 0x12 i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(size))
} }
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(baseI-i))
i-- i--
dAtA[i] = 0x62 dAtA[i] = 0x62
} }
@ -776,13 +741,10 @@ func (m *Feature) Size() (n int) {
} }
var l int var l int
_ = l _ = l
l = len(m.ValueStr) l = len(m.Description)
if l > 0 { if l > 0 {
n += 1 + l + sovPaymentserviceTiers(uint64(l)) n += 1 + l + sovPaymentserviceTiers(uint64(l))
} }
if m.ValueUint != 0 {
n += 1 + sovPaymentserviceTiers(uint64(m.ValueUint))
}
return n return n
} }
@ -800,9 +762,6 @@ func (m *GetTiersRequest) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovPaymentserviceTiers(uint64(l)) n += 1 + l + sovPaymentserviceTiers(uint64(l))
} }
if m.PaymentMethod != 0 {
n += 1 + sovPaymentserviceTiers(uint64(m.PaymentMethod))
}
return n return n
} }
@ -865,18 +824,15 @@ func (m *TierData) Size() (n int) {
n += 1 + sovPaymentserviceTiers(uint64(m.AnyNameMinLength)) n += 1 + sovPaymentserviceTiers(uint64(m.AnyNameMinLength))
} }
if len(m.Features) > 0 { if len(m.Features) > 0 {
for k, v := range m.Features { for _, e := range m.Features {
_ = k l = e.Size()
_ = v n += 1 + l + sovPaymentserviceTiers(uint64(l))
l = 0
if v != nil {
l = v.Size()
l += 1 + sovPaymentserviceTiers(uint64(l))
}
mapEntrySize := 1 + len(k) + sovPaymentserviceTiers(uint64(len(k))) + l
n += mapEntrySize + 1 + sovPaymentserviceTiers(uint64(mapEntrySize))
} }
} }
l = len(m.ColorStr)
if l > 0 {
n += 1 + l + sovPaymentserviceTiers(uint64(l))
}
return n return n
} }
@ -932,7 +888,7 @@ func (m *Feature) Unmarshal(dAtA []byte) error {
switch fieldNum { switch fieldNum {
case 1: case 1:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ValueStr", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
} }
var stringLen uint64 var stringLen uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -960,27 +916,8 @@ func (m *Feature) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.ValueStr = string(dAtA[iNdEx:postIndex]) m.Description = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ValueUint", wireType)
}
m.ValueUint = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPaymentserviceTiers
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ValueUint |= uint32(b&0x7F) << shift
if b < 0x80 {
break
}
}
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:]) skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:])
@ -1095,25 +1032,6 @@ func (m *GetTiersRequest) Unmarshal(dAtA []byte) error {
} }
m.Locale = string(dAtA[iNdEx:postIndex]) m.Locale = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field PaymentMethod", wireType)
}
m.PaymentMethod = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPaymentserviceTiers
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.PaymentMethod |= uint32(b&0x7F) << shift
if b < 0x80 {
break
}
}
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:]) skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:])
@ -1549,105 +1467,42 @@ func (m *TierData) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.Features == nil { m.Features = append(m.Features, &Feature{})
m.Features = make(map[string]*Feature) if err := m.Features[len(m.Features)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
} }
var mapkey string iNdEx = postIndex
var mapvalue *Feature case 13:
for iNdEx < postIndex { if wireType != 2 {
entryPreIndex := iNdEx return fmt.Errorf("proto: wrong wireType = %d for field ColorStr", wireType)
var wire uint64 }
for shift := uint(0); ; shift += 7 { var stringLen uint64
if shift >= 64 { for shift := uint(0); ; shift += 7 {
return ErrIntOverflowPaymentserviceTiers if shift >= 64 {
} return ErrIntOverflowPaymentserviceTiers
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
} }
fieldNum := int32(wire >> 3) if iNdEx >= l {
if fieldNum == 1 { return io.ErrUnexpectedEOF
var stringLenmapkey uint64 }
for shift := uint(0); ; shift += 7 { b := dAtA[iNdEx]
if shift >= 64 { iNdEx++
return ErrIntOverflowPaymentserviceTiers stringLen |= uint64(b&0x7F) << shift
} if b < 0x80 {
if iNdEx >= l { break
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var mapmsglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPaymentserviceTiers
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapmsglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if mapmsglen < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
postmsgIndex := iNdEx + mapmsglen
if postmsgIndex < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
if postmsgIndex > l {
return io.ErrUnexpectedEOF
}
mapvalue = &Feature{}
if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
return err
}
iNdEx = postmsgIndex
} else {
iNdEx = entryPreIndex
skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
} }
} }
m.Features[mapkey] = mapvalue intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthPaymentserviceTiers
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ColorStr = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex

View file

@ -60,8 +60,8 @@ message GetSubscriptionRequestSigned {
} }
message GetSubscriptionResponse { message GetSubscriptionResponse {
// was SubscriptionTier before, changed to int32 to allow us to use dynamic tiers // was SubscriptionTier before, changed to uint32 to allow us to use dynamic tiers
int32 tier = 1; uint32 tier = 1;
SubscriptionStatus status = 2; SubscriptionStatus status = 2;
uint64 dateStarted = 3; uint64 dateStarted = 3;
uint64 dateEnds = 4; uint64 dateEnds = 4;
@ -82,8 +82,8 @@ message BuySubscriptionRequest {
// this is required to reserve a name for the owner (later that is done by user) // this is required to reserve a name for the owner (later that is done by user)
// in the following format: "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" // in the following format: "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"
string ownerEthAddress = 2; string ownerEthAddress = 2;
// was SubscriptionTier before, changed to int32 to allow us to use dynamic tiers // was SubscriptionTier before, changed to uint32 to allow us to use dynamic tiers
int32 requestedTier = 3; uint32 requestedTier = 3;
PaymentMethod paymentMethod = 4; PaymentMethod paymentMethod = 4;
// if empty - then no name requested // if empty - then no name requested
// if non-empty - PP node will register that name on behalf of the user // if non-empty - PP node will register that name on behalf of the user
@ -101,6 +101,8 @@ message BuySubscriptionResponse {
// will feature current billing ID // will feature current billing ID
// stripe.com/?client_reference_id=1234 // stripe.com/?client_reference_id=1234
string paymentUrl = 1; string paymentUrl = 1;
// billingID is passed via mobile client to payment platform
string billingID = 2;
} }
message FinalizeSubscriptionRequest { message FinalizeSubscriptionRequest {
@ -188,7 +190,7 @@ message VerifyEmailRequestSigned {
} }
message IsNameValidRequest { message IsNameValidRequest {
int32 requestedTier = 1; uint32 requestedTier = 1;
string requestedAnyName = 2; string requestedAnyName = 2;
} }
@ -208,6 +210,32 @@ message IsNameValidResponse {
} }
} }
enum ErrorCodes {
Unexpected = 0;
EthAddressEmpty = 1;
InvalidSignature = 2;
TierWrong = 3;
TierNotFound = 4;
TierInactive = 5;
PaymentMethodWrong = 6;
BadAnyName = 7;
Unknown = 8;
SubsAlreadyActive = 9;
SubsNotFound = 10;
SubsWrongState = 11;
EmailWrongFormat = 12;
EmailAlreadyVerified = 13;
EmailAlreadySent = 14;
EmailFailedToSend = 15;
EmailExpired = 16;
EmailWrongCode = 17;
ErrorOffset = 600;
}
// NOTICE: // NOTICE:
// 1 - User can not ask for a payment/other links on behalf of another user (a signature is required) // 1 - User can not ask for a payment/other links on behalf of another user (a signature is required)
// 2 - Admin can do that on behalf of any user // 2 - Admin can do that on behalf of any user

View file

@ -12,14 +12,7 @@ enum PeriodType {
} }
message Feature { message Feature {
// "invites" string description = 1;
// "GBs"
// "spaces"
// ...
string valueStr = 1;
// each uint is a value of the feature
uint32 valueUint = 2;
} }
message GetTiersRequest { message GetTiersRequest {
@ -28,9 +21,6 @@ message GetTiersRequest {
string ownerAnyId = 1; string ownerAnyId = 1;
string locale = 2; string locale = 2;
// see PaymentMethod enum
uint32 paymentMethod = 3;
} }
message GetTiersRequestSigned { message GetTiersRequestSigned {
@ -68,9 +58,9 @@ message TierData {
// somename.any - len of 8 // somename.any - len of 8
uint32 anyNameMinLength = 11; uint32 anyNameMinLength = 11;
// each tier has a set of features // each tier has a set of features
// each feature has a unique key: "storage", "invites", etc repeated Feature features = 12;
// not using enum here to provide dynamic feature list // green, blue, red, purple or custom color in string format #ff00ff
map<string, Feature> features = 12; string colorStr = 13;
} }
message GetTiersResponse { message GetTiersResponse {

View file

@ -3,10 +3,12 @@ package periodicsync
import ( import (
"context" "context"
"github.com/anyproto/any-sync/app/logger"
"go.uber.org/zap"
"sync/atomic" "sync/atomic"
"time" "time"
"go.uber.org/zap"
"github.com/anyproto/any-sync/app/logger"
) )
type PeriodicSync interface { type PeriodicSync interface {
@ -17,39 +19,40 @@ type PeriodicSync interface {
type SyncerFunc func(ctx context.Context) error type SyncerFunc func(ctx context.Context) error
func NewPeriodicSync(periodSeconds int, timeout time.Duration, caller SyncerFunc, l logger.CtxLogger) PeriodicSync { func NewPeriodicSync(periodSeconds int, timeout time.Duration, caller SyncerFunc, l logger.CtxLogger) PeriodicSync {
// TODO: rename to PeriodicCall (including folders) and do PRs in all repos where we are using this return NewPeriodicSyncDuration(time.Duration(periodSeconds)*time.Second, timeout, caller, l)
// https://linear.app/anytype/issue/GO-1241/change-periodicsync-component-to-periodiccall }
func NewPeriodicSyncDuration(periodicLoopInterval, timeout time.Duration, caller SyncerFunc, l logger.CtxLogger) PeriodicSync {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
ctx = logger.CtxWithFields(ctx, zap.String("rootOp", "periodicCall")) ctx = logger.CtxWithFields(ctx, zap.String("rootOp", "periodicCall"))
return &periodicCall{ return &periodicCall{
caller: caller, caller: caller,
log: l, log: l,
loopCtx: ctx, loopCtx: ctx,
loopCancel: cancel, loopCancel: cancel,
loopDone: make(chan struct{}), loopDone: make(chan struct{}),
periodSeconds: periodSeconds, period: periodicLoopInterval,
timeout: timeout, timeout: timeout,
} }
} }
type periodicCall struct { type periodicCall struct {
log logger.CtxLogger log logger.CtxLogger
caller SyncerFunc caller SyncerFunc
loopCtx context.Context loopCtx context.Context
loopCancel context.CancelFunc loopCancel context.CancelFunc
loopDone chan struct{} loopDone chan struct{}
periodSeconds int period time.Duration
timeout time.Duration timeout time.Duration
isRunning atomic.Bool isRunning atomic.Bool
} }
func (p *periodicCall) Run() { func (p *periodicCall) Run() {
p.isRunning.Store(true) p.isRunning.Store(true)
go p.loop(p.periodSeconds) go p.loop(p.period)
} }
func (p *periodicCall) loop(periodSeconds int) { func (p *periodicCall) loop(period time.Duration) {
period := time.Duration(periodSeconds) * time.Second
defer close(p.loopDone) defer close(p.loopDone)
doCall := func() { doCall := func() {
ctx := p.loopCtx ctx := p.loopCtx