1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00
Shared library for Anytype clients https://anytype.io
Find a file
2023-01-16 14:02:52 +01:00
.githooks GO-478 Make a task number in a commit message mandatory 2022-10-28 17:52:05 +03:00
.github ci: fix linux arm64 build 2023-01-12 17:42:11 +01:00
app Fix linter 2022-12-15 23:37:03 +05:00
change Merge branch 'master' of github.com:anytypeio/go-anytype-middleware into go-551-remove-unused-code 2023-01-12 16:12:43 +08:00
clientlibrary GO-551: fix conflicts 2023-01-16 17:28:03 +08:00
cmd GO-370 Migrate peerstore 2022-11-03 22:07:08 +03:00
core Merge pull request #1700 from anytypeio/fix-setof-featrel-go-739 2023-01-16 11:40:34 +01:00
dist fix typo 2022-06-27 19:46:50 +03:00
docs small fixes 2023-01-09 13:42:49 +01:00
metrics remove debug metrics printing 2022-07-23 16:48:03 +02:00
pb GO-551: fix conflicts 2023-01-16 17:28:03 +08:00
pkg/lib GO-230 Fix error handling on enocding 2023-01-16 11:42:49 +01:00
tests Fix tests 2022-12-12 20:10:59 +05:00
util Merge branch 'master' of ssh://github.com/anytypeio/go-anytype-middleware into fix-pb-nil 2023-01-16 11:37:32 +01: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 Fix tests 2022-12-12 20:10:59 +05:00
.golangci.yml GO-572 notion import performance impovement, bug fixes and rollup property support (#1655) 2022-12-16 17:28:20 +03:00
.pre-commit-config.yaml Merge branch 'master' of ssh://github.com/anytypeio/go-anytype-middleware into ref-sb-cache 2021-09-02 17:59:33 +04:00
build.gradle ci: publish to maven 2021-10-06 14:33:20 +04:00
docker-compose.yml GO-511 ANYTYPE_TEST_GRPC_PORT became mandatory 2022-12-05 14:20:26 +05:00
Dockerfile GO-511 Smoke test 2022-12-01 18:16:10 +05:00
go.mod Merge branch 'master' of ssh://github.com/anytypeio/go-anytype-middleware into fix-pb-nil 2023-01-16 11:37:32 +01:00
go.sum Merge branch 'master' of ssh://github.com/anytypeio/go-anytype-middleware into fix-pb-nil 2023-01-16 11:37:32 +01:00
Makefile GO-477: retrieve tables and columns from notion api (#1638) 2022-12-16 11:06:54 +03:00
package.json ci fixes 2022-02-03 15:16:01 +01:00
README.md Readme: protobuf version 2023-01-16 14:02:52 +01: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.18.* 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 ../js-anytype

Build for iOS

Instructions to setup 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 anytypeio/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:

make test-deps

GO test:

make test

NodeJS addon test:

cd jsaddon
npm run test

Integration tests (WIP)

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

docker-compose up -d

Then

make test-integration

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

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

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:
    • Threads gRPC client for go-threads client metrics(when you make requests to other nodes)
    • Threads gRPC server for go-threads server metrics(when other nodes make requests to you)
    • 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