Skip to content

Commit

Permalink
Merge pull request #92 from anyproto/GO-1505-update-any-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrakhman authored Jun 13, 2023
2 parents 23cf287 + d2c4e77 commit e41af55
Show file tree
Hide file tree
Showing 11 changed files with 4,984 additions and 4,953 deletions.
6 changes: 3 additions & 3 deletions core/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (mw *Middleware) AccountCreate(cctx context.Context, req *pb.RpcAccountCrea
mw.EventSender,
}

if mw.app, err = anytype.StartNewApp(context.WithValue(context.Background(), metrics.CtxKeyRequest, "account_create"), comps...); err != nil {
if mw.app, err = anytype.StartNewApp(context.WithValue(context.Background(), metrics.CtxKeyRequest, "account_create"), mw.clientVersion, comps...); err != nil {
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE, err)
}

Expand Down Expand Up @@ -303,7 +303,7 @@ func (mw *Middleware) AccountSelect(cctx context.Context, req *pb.RpcAccountSele
// if we have created the repo, we need to highlight that we are recovering the account
request = request + "_recover"
}
if mw.app, err = anytype.StartNewApp(context.WithValue(context.Background(), metrics.CtxKeyRequest, request), comps...); err != nil {
if mw.app, err = anytype.StartNewApp(context.WithValue(context.Background(), metrics.CtxKeyRequest, request), mw.clientVersion, comps...); err != nil {
if errors.Is(err, spacesyncproto.ErrSpaceMissing) {
return response(nil, pb.RpcAccountSelectResponseError_FAILED_TO_FIND_ACCOUNT_INFO, err)
}
Expand Down Expand Up @@ -655,7 +655,7 @@ func (mw *Middleware) startApp(cfg *config.Config, derivationResult crypto.Deriv

ctxWithValue := context.WithValue(context.Background(), metrics.CtxKeyRequest, "account_create")
var err error
if mw.app, err = anytype.StartNewApp(ctxWithValue, comps...); err != nil {
if mw.app, err = anytype.StartNewApp(ctxWithValue, mw.clientVersion, comps...); err != nil {
return err
}
return nil
Expand Down
10 changes: 9 additions & 1 deletion core/anytype/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import (
"github.com/anyproto/anytype-heart/util/builtintemplate"
"github.com/anyproto/anytype-heart/util/linkpreview"
"github.com/anyproto/anytype-heart/util/unsplash"
"github.com/anyproto/anytype-heart/util/vcs"
)

func BootstrapConfig(newAccount bool, isStaging bool, createBuiltinTemplates bool) *config.Config {
Expand All @@ -86,8 +87,9 @@ func BootstrapWallet(rootPath string, derivationResult crypto.DerivationResult)
return wallet.NewWithAccountRepo(rootPath, derivationResult)
}

func StartNewApp(ctx context.Context, components ...app.Component) (a *app.App, err error) {
func StartNewApp(ctx context.Context, clientVersion string, components ...app.Component) (a *app.App, err error) {
a = new(app.App)
a.SetVersionName(appVersion(a, clientVersion))
Bootstrap(a, components...)
metrics.SharedClient.SetAppVersion(a.Version())
metrics.SharedClient.Run()
Expand All @@ -100,6 +102,12 @@ func StartNewApp(ctx context.Context, components ...app.Component) (a *app.App,
return
}

func appVersion(a *app.App, clientVersion string) string {
middleVersion := vcs.GetVCSInfo().Version()
anySyncVersion := a.AnySyncVersion()
return "client:" + clientVersion + "/middle:" + middleVersion + "/any-sync:" + anySyncVersion
}

func Bootstrap(a *app.App, components ...app.Component) {
for _, c := range components {
a.Register(c)
Expand Down
2 changes: 1 addition & 1 deletion core/block/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (s *Service) getDerivedObject(
optsKey,
cacheOpts{
buildOption: source.BuildOptions{
RetryRemoteLoad: true,
// TODO: revive p2p (right now we are not ready to load from local clients due to the fact that we need to know when local peers connect)
},
},
)
Expand Down
4 changes: 1 addition & 3 deletions core/block/source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ func (s *service) Name() (name string) {

type BuildOptions struct {
DisableRemoteLoad bool
RetryRemoteLoad bool // anysync only; useful for account cold load from p2p nodes
Listener updatelistener.UpdateListener
}

func (b *BuildOptions) BuildTreeOpts() objecttreebuilder.BuildTreeOpts {
return objecttreebuilder.BuildTreeOpts{
Listener: b.Listener,
WaitTreeRemoteSync: b.RetryRemoteLoad,
Listener: b.Listener,
}
}

Expand Down
5 changes: 3 additions & 2 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type Middleware struct {
accountSearchCancel context.CancelFunc
EventSender event.Sender

sessions session.Service
app *app.App
sessions session.Service
clientVersion string
app *app.App

m sync.RWMutex
}
Expand Down
1 change: 1 addition & 0 deletions core/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func (mw *Middleware) MetricsSetParameters(cctx context.Context, req *pb.RpcMetr

return m
}
mw.clientVersion = req.Platform + "-" + req.Version
metrics.SharedClient.SetPlatform(req.Platform)

return response(pb.RpcMetricsSetParametersResponseError_NULL, nil)
Expand Down
8,133 changes: 4,067 additions & 4,066 deletions docs/proto.md

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/VividCortex/ewma v1.2.0
github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
github.com/anyproto/any-sync v0.2.1
github.com/anyproto/any-sync v0.2.3
github.com/anyproto/go-naturaldate/v2 v2.0.2-0.20230524105841-9829cfd13438
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/blevesearch/bleve/v2 v2.3.8
Expand Down Expand Up @@ -45,9 +45,9 @@ require (
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-flatfs v0.5.1
github.com/ipfs/go-ipfs-ds-help v1.1.1
github.com/ipfs/go-ipld-format v0.4.0
github.com/ipfs/go-ipld-format v0.5.0
github.com/ipfs/go-log v1.0.5
github.com/ipfs/go-merkledag v0.10.0
github.com/ipfs/go-merkledag v0.11.0
github.com/ipfs/go-path v0.3.1
github.com/ipfs/go-unixfs v0.4.6
github.com/ipfs/interface-go-ipfs-core v0.11.2
Expand Down Expand Up @@ -172,8 +172,7 @@ require (
github.com/ipfs/go-ipfs-files v0.3.0 // indirect
github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipld-cbor v0.0.6 // indirect
github.com/ipfs/go-ipld-legacy v0.1.1 // indirect
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
github.com/ipfs/go-libipfs v0.4.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
Expand Down Expand Up @@ -219,7 +218,6 @@ require (
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect
Expand All @@ -234,7 +232,6 @@ require (
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
Expand Down
Loading

0 comments on commit e41af55

Please sign in to comment.