Skip to content

Commit

Permalink
Merge pull request #4 from anyproto/new-sync-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrakhman authored Jun 9, 2023
2 parents 11e6ef9 + 348bf7a commit 8e354a2
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 45 deletions.
11 changes: 7 additions & 4 deletions cmd/filenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (
"github.com/anyproto/any-sync/coordinator/coordinatorclient"
"github.com/anyproto/any-sync/coordinator/nodeconfsource"
"github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/net/dialer"
"github.com/anyproto/any-sync/net/peerservice"
"github.com/anyproto/any-sync/net/pool"
"github.com/anyproto/any-sync/net/rpc/server"
"github.com/anyproto/any-sync/net/secureservice"
"github.com/anyproto/any-sync/net/transport/yamux"
"github.com/anyproto/any-sync/nodeconf"
"github.com/anyproto/any-sync/nodeconf/nodeconfstore"
"go.uber.org/zap"
Expand Down Expand Up @@ -103,15 +104,17 @@ func Bootstrap(a *app.App) {
Register(nodeconfsource.New()).
Register(nodeconfstore.New()).
Register(nodeconf.New()).
Register(dialer.New()).
Register(peerservice.New()).
Register(secureservice.New()).
Register(yamux.New()).
Register(pool.New()).
Register(coordinatorclient.New()).
Register(limit.New()).
Register(store()).
Register(redisprovider.New()).
Register(redisindex.New()).
Register(filenode.New()).
Register(metric.New()).
Register(server.New()).
Register(metric.New())
Register(filenode.New())

}
6 changes: 3 additions & 3 deletions cmd/filenode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
commonaccount "github.com/anyproto/any-sync/accountservice"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/net"
"github.com/anyproto/any-sync/net/rpc"
"github.com/stretchr/testify/require"
"os"
"testing"
Expand All @@ -24,8 +24,8 @@ func TestBootstrap(t *testing.T) {
PeerKey: "X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==",
SigningKey: "X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==",
},
GrpcServer: net.Config{},
Metric: metric.Config{},
Drpc: rpc.Config{},
Metric: metric.Config{},
S3Store: s3store.Config{
Bucket: "test",
},
Expand Down
14 changes: 10 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
commonaccount "github.com/anyproto/any-sync/accountservice"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/net"
"github.com/anyproto/any-sync/net/rpc"
"github.com/anyproto/any-sync/net/transport/yamux"
"github.com/anyproto/any-sync/nodeconf"
"gopkg.in/yaml.v3"
"os"
Expand All @@ -28,7 +29,8 @@ func NewFromFile(path string) (c *Config, err error) {

type Config struct {
Account commonaccount.Config `yaml:"account"`
GrpcServer net.Config `yaml:"grpcServer"`
Drpc rpc.Config `yaml:"drpc"`
Yamux yamux.Config `yaml:"yamux"`
Metric metric.Config `yaml:"metric"`
S3Store s3store.Config `yaml:"s3Store"`
FileDevStore FileDevStore `yaml:"fileDevStore"`
Expand Down Expand Up @@ -58,8 +60,8 @@ func (c Config) GetDevStore() FileDevStore {
return c.FileDevStore
}

func (c Config) GetNet() net.Config {
return c.GrpcServer
func (c Config) GetDrpc() rpc.Config {
return c.Drpc
}

func (c Config) GetMetric() metric.Config {
Expand All @@ -81,3 +83,7 @@ func (c Config) GetNodeConfStorePath() string {
func (c Config) GetNodeConfUpdateInterval() int {
return c.NetworkUpdateIntervalSec
}

func (c Config) GetYamux() yamux.Config {
return c.Yamux
}
37 changes: 19 additions & 18 deletions etc/any-sync-filenode.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
account:
peerId: 12D3KooWQxiZ5a7vcy4DTJa8Gy1eVUmwb5ojN4SrJC9Rjxzigw6C
peerKey: X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==
signingKey: X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==
grpcServer:
server:
listenAddrs:
- 127.0.0.1:4730
stream:
timeoutMilliseconds: 1000
maxMsgSizeMb: 256
peerId: 12D3KooWQxiZ5a7vcy4DTJa8Gy1eVUmwb5ojN4SrJC9Rjxzigw6C
peerKey: X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==
signingKey: X7YT92hRIQf42tNiIlOS01p1uJiPSqcdkE6LViS8PxnhAv/28YzTctqPjm11AC63Dq7ybmwPQiBu1pwa3AxHzQ==
drpc:
stream:
maxMsgSizeMb: 256
yamux:
listenAddrs:
- 127.0.0.1:4730
writeTimeoutSec: 10
dialTimeoutSec: 10
metric:
addr: ":7010"
addr: ":7010"
s3Store:
region: eu-central-1
profile: default
bucket: anytype-test
maxThreads: 16
region: eu-central-1
profile: default
bucket: anytype-test
maxThreads: 16

redis:
isCluster: false
url: "redis://127.0.0.1:6379/?dial_timeout=3&db=1&read_timeout=6s&max_retries=2"
isCluster: false
url: "redis://127.0.0.1:6379/?dial_timeout=3&db=1&read_timeout=6s&max_retries=2"

fileDevStore:
path: db
path: db

network:
id: 64384a038e697b7fce2f447e
Expand Down
8 changes: 4 additions & 4 deletions filenode/filenode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/anyproto/any-sync/commonfile/fileproto"
"github.com/anyproto/any-sync/commonfile/fileproto/fileprotoerr"
"github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/net/rpc/rpctest"
"github.com/anyproto/any-sync/net/rpc/server"
"github.com/golang/mock/gomock"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -225,7 +225,7 @@ func newFixture(t *testing.T) *fixture {
index: mock_index.NewMockIndex(ctrl),
store: mock_store.NewMockStore(ctrl),
limit: mock_limit.NewMockLimit(ctrl),
serv: rpctest.NewTestServer(),
serv: server.New(),
ctrl: ctrl,
a: new(app.App),
}
Expand All @@ -241,7 +241,7 @@ func newFixture(t *testing.T) *fixture {
fx.limit.EXPECT().Run(gomock.Any()).AnyTimes()
fx.limit.EXPECT().Close(gomock.Any()).AnyTimes()

fx.a.Register(fx.serv).Register(fx.index).Register(fx.store).Register(fx.limit).Register(fx.fileNode).Register(metric.New()).Register(&config.Config{})
fx.a.Register(metric.New()).Register(fx.serv).Register(fx.index).Register(fx.store).Register(fx.limit).Register(fx.fileNode).Register(&config.Config{})
require.NoError(t, fx.a.Start(ctx))
return fx
}
Expand All @@ -253,7 +253,7 @@ type fixture struct {
ctrl *gomock.Controller
a *app.App
limit *mock_limit.MockLimit
serv *rpctest.TesServer
serv server.DRPCServer
}

func (fx *fixture) Finish(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/ahmetb/govvv v0.3.0
github.com/anyproto/any-sync v0.1.1
github.com/anyproto/any-sync v0.2.0
github.com/aws/aws-sdk-go v1.44.275
github.com/go-redsync/redsync/v4 v4.8.1
github.com/gogo/protobuf v1.3.2
Expand All @@ -13,7 +13,7 @@ require (
github.com/ipfs/go-block-format v0.1.2
github.com/ipfs/go-cid v0.4.1
github.com/redis/go-redis/v9 v9.0.5
github.com/stretchr/testify v1.8.3
github.com/stretchr/testify v1.8.4
go.uber.org/atomic v1.11.0
go.uber.org/zap v1.24.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -35,13 +35,14 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-libp2p v0.27.3 // indirect
github.com/libp2p/go-libp2p v0.27.5 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
Expand All @@ -51,7 +52,7 @@ require (
github.com/multiformats/go-multiaddr v0.9.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multihash v0.2.2 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0=
github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s=
github.com/anyproto/any-sync v0.1.1 h1:fZ6SfiSf4tX3Ab+76cZAxAm/3uY60lnndyBgeqenT8w=
github.com/anyproto/any-sync v0.1.1/go.mod h1:N56AZy/MmqabgNPWc4+Ta6Tbkk0Ob7sYLfNpzK4Hv7M=
github.com/anyproto/any-sync v0.2.0 h1:7xebKZZzoR0ZN3ZLEQQYRDmuwTFB0JfLtC788BuooCE=
github.com/anyproto/any-sync v0.2.0/go.mod h1:9mBFhqgDbUcxU9gxiyniNUQMfsUcD0eCjLIc6rgh2uk=
github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY=
github.com/anyproto/go-chash v0.1.0/go.mod h1:0UjNQi3PDazP0fINpFYu6VKhuna+W/V+1vpXHAfNgLY=
github.com/anyproto/go-slip10 v1.0.0 h1:uAEtSuudR3jJBOfkOXf3bErxVoxbuKwdoJN55M1i6IA=
Expand Down Expand Up @@ -81,6 +81,8 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo=
github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE=
Expand Down Expand Up @@ -108,8 +110,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/libp2p/go-libp2p v0.27.3 h1:tkV/zm3KCZ4R5er9Xcs2pt0YNB4JH0iBfGAtHJdLHRs=
github.com/libp2p/go-libp2p v0.27.3/go.mod h1:FAvvfQa/YOShUYdiSS03IR9OXzkcJXwcNA2FUCh9ImE=
github.com/libp2p/go-libp2p v0.27.5 h1:KwA7pXKXpz8hG6Cr1fMA7UkgleogcwQj0sxl5qquWRg=
github.com/libp2p/go-libp2p v0.27.5/go.mod h1:oMfQGTb9CHnrOuSM6yMmyK2lXz3qIhnkn2+oK3B1Y2g=
github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0=
github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
Expand All @@ -135,8 +137,8 @@ github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6o
github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg=
github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k=
github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108=
github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc=
github.com/multiformats/go-multihash v0.2.2 h1:Uu7LWs/PmWby1gkj1S1DXx3zyd3aVabA4FiMKn/2tAc=
github.com/multiformats/go-multihash v0.2.2/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM=
github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo=
github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q=
github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
Expand Down Expand Up @@ -181,8 +183,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
Expand Down

0 comments on commit 8e354a2

Please sign in to comment.