1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-08 05:47:07 +09:00
Shared library for Anytype clients https://anytype.io
Find a file
AnastasiaShemyakinskaya ba6638fb22
GO-1490: fix for test
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
2023-07-04 11:01:18 +02:00
.githooks GO-879 Add pre-commit secrets linter 2023-04-25 18:17:59 +02:00
.github Mirror any block (#107) 2023-06-21 15:54:31 +03:00
.idea GO-1330 Fix rebase changes 2023-04-25 18:17:59 +02:00
.run GO-1330 Fix rebase changes 2023-05-24 17:10:52 +02:00
app/testapp improve log app start debug 2023-06-23 15:59:36 +02:00
clientlibrary GO-1353 merge main 2023-06-09 16:27:33 +02:00
cmd GO-1561 merge main 2023-06-30 18:49:36 +02:00
core GO-1490: fix for test 2023-07-04 11:01:18 +02:00
deps fix CI 2023-05-25 16:47:53 +02:00
dist fix makefile 2023-06-01 15:56:05 +02:00
docs GO-1597 Add default template relation and view field 2023-06-26 17:15:42 +02:00
metrics improve log app start debug 2023-06-23 15:59:36 +02:00
net/addrs GO-1330 Fix rebase changes 2023-05-24 17:10:52 +02:00
pb Update any-sync: yamux, clientVersion and retry timeout 2023-06-13 17:17:04 +02:00
pkg/lib GO-1490: add cache for state 2023-07-04 10:41:14 +02:00
space improve log app start debug 2023-06-23 15:59:36 +02:00
tests GO-1330 Fix rebase changes 2023-05-24 17:10:52 +02:00
util GO-1490: add cache for state 2023-07-04 10:41:14 +02:00
.dockerignore GO-511 Smoke test 2022-12-01 18:16:10 +05:00
.gitattributes lib.so moved to dist/ and updated 2019-09-26 22:56:33 +03:00
.gitignore update maven package name 2023-06-05 15:00:39 +02:00
.golangci.yml GO-1483: Please linter 2023-06-21 18:25:22 +05:00
.mockery.yaml GO-1482: Object store: full-text tests 2023-06-08 15:51:23 +05:00
.pre-commit-config.yaml GO-879 Add pre-commit secrets linter 2023-04-25 18:17:59 +02:00
build.gradle update maven package name 2023-06-05 15:00:39 +02:00
docker-compose.yml GO-1330 Fix rebase changes 2023-05-24 17:10:52 +02:00
Dockerfile GO-1077: Update Readme and Dockerfile 2023-04-25 18:17:59 +02:00
go.mod Bump github.com/shirou/gopsutil/v3 from 3.23.5 to 3.23.6 2023-07-03 04:42:43 +00:00
go.sum Bump github.com/shirou/gopsutil/v3 from 3.23.5 to 3.23.6 2023-07-03 04:42:43 +00:00
Makefile GO-1482: Fix readme and Makefile 2023-06-08 15:56:52 +05:00
package.json GO-1330 Fix rebase changes 2023-05-24 17:10:52 +02:00
README.md GO-1533: Better debug server; add readme 2023-06-22 12:22:04 +05:00
webpack.config.js add webpack umd library options 2020-06-22 16:22:28 +03:00

Anytype Middleware Library

Build from Source

  1. Install Golang 1.19+ from here or using preferred package manager
  2. Follow instructions below for the target systems

Build and install for the desktop client

  1. make install-dev-js to build the local server and copy it and protobuf binding into ../anytype-ts

Build for iOS

Instructions to set up environment for ios here

  1. make build-ios to build the framework into dist/ios folder
  2. make protos-swift to generate swift protobuf bindings into dist/ios/pb

Build for Android

Instructions to setup environment for android here

  1. make build-android to build the library into dist/android folder
  2. make protos-java to generate java protobuf bindings into dist/android/pb

Rebuild protobuf generated files

First, you need to install protobuf pkg using your preferred package manager. This repo uses custom protoc located at anyproto/protobuf. It adds gomobile plugin and some env-controlled options to control the generated code style. This protobuf generator will replace your protoc binary, BTW it doesn't have any breaking changes for other protobuf and grpc code

You can override the binary with a simple command:

make setup-protoc

Then you can easily regenerate proto files:

make protos

Run tests

Generate mocks:

Install Mockery https://vektra.github.io/mockery/installation/

make test-deps

GO test:

make test

You'll need to install latest (at least clang 15)

brew install llvm 
echo 'export PATH="/<homebrew location>/llvm/bin:$PATH"' >> ~/.zshrc 

NodeJS addon test:

cd jsaddon
npm run test

Integration and migration tests

You need a Github Token in order to access out private repos while building the docker image.

Migration tests are checking process of migration from the old infrastructure.

First you need to start a docker container via docker-compose:

export GITHUB_LOGIN=<your github login>
export GITHUB_TOKEN=<your github token>
export ANYTYPE_TEST_GRPC_PORT=31088
export ANYTYPE_OLD_TEST_GRPC_PORT=31188
docker-compose up -d

Then you can run the basic integration tests:

make test-integration

And migration tests:

make test-migration

Run local gRPC server to debug

⚠️ Make sure to update/install protobuf compiler from this repo using make setup-protoc

Commands:

  • make run-server - builds proto files for grpc server, builds the binary and runs it
  • make build-server - builds proto files for grpc server and builds the binary into dist/server

If you want to change the default port(9999):

ANYTYPE_GRPC_ADDR=127.0.0.1:8888 make run-debug


Useful tools for debug

Debug server

Use env var ANYDEBUG=address to enable debugging HTTP server. For example: ANYDEBUG=:6061 will start debug server on port 6061

You can find all endpoints in /debug page. For example: http://localhost:6061/debug

gRPC logging

In order to log mw gRPC requests/responses use ANYTYPE_GRPC_LOG env var:

  • ANYTYPE_LOG_LEVEL="grpc=DEBUG" ANYTYPE_GRPC_LOG=1 - log only method names
  • ANYTYPE_LOG_LEVEL="grpc=DEBUG" ANYTYPE_GRPC_LOG=2 - log method names + payloads for commands
  • ANYTYPE_LOG_LEVEL="grpc=DEBUG" ANYTYPE_GRPC_LOG=2 - log method names + payloads for commands&events

gRPC tracing

  1. Run jaeger UI on the local machine: docker run --rm -d -p6832:6832/udp -p6831:6831/udp -p16686:16686 -p5778:5778 -p5775:5775/udp jaegertracing/all-in-one:latest
  2. Run mw with ANYTYPE_GRPC_TRACE env var:
  • ANYTYPE_GRPC_TRACE=1 - log only method names/times
  • ANYTYPE_GRPC_TRACE=2 - log method names + payloads for commands
  • ANYTYPE_GRPC_TRACE=2 - log method names + payloads for commands&events
  1. Open Jaeger UI at http://localhost:16686

Debug tree

  1. You can use cmd/debugtree.go to perform different operations with tree exported in zip archive (rpc DebugTree)
  2. The usage looks like this go run debugtree.go -j -t -f [path to zip archive] where -t tells the cmd to generate tree graph view and -j - to generate json representation of the tree (i.e. data in each individual block)
  3. You can use flag -r to build the tree from its root, that way you will see all the changes in the tree, and not only those from the common snapshot
  4. For more info please check the command usage in debugtree.go

GUI

https://github.com/uw-labs/bloomrpc

HowTo: Set the import path to the middleware root, then select commands.proto file

CLI

https://github.com/njpatel/grpcc

Running with prometheus and grafana

  • cd metrics/docker cd into folder with docker-compose file
  • docker-compose up - run the prometheus/grafana
  • use ANYTYPE_PROM=0.0.0.0:9094 when running middleware to enable metrics collection. Client commands metrics available only in gRPC mode
  • open http://127.0.0.1:3000 to view collected metrics in Grafana. You can find several dashboards there:
    • MW internal middleware metrics such as changes, added and created threads histograms
    • MW commands server metrics for clients commands. Works only in grpc-server mode

Install local deps(Mac)

As of 16.01.23 last protobuf version(21.12) broke the JS plugin support, so you can use the v3 branch

brew install protobuf@3

To generate Swift protobuf:

brew install swift-protobuf