Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch events over gRPC #2231

Closed
wants to merge 8 commits into from

Conversation

abichinger
Copy link
Contributor

@abichinger abichinger commented Apr 10, 2023

I have been playing around with gRPC as an alternative to dart:ffi. So far I only tried it on my local system with a single user.

Generating dart files

mkdir appflowy_flutter/packages/appflowy_backend/lib/protobuf/flowy-grpc
protoc --dart_out=grpc:appflowy_flutter/packages/appflowy_backend/lib/protobuf/flowy-grpc -I rust-lib/flowy-grpc/proto flowygrpc.proto

The code generation should be done inside flowy_codegen, but I couldn't figure out how to do that.

Running the server

cd rust-lib/flowy-grpc
RUST_LOG=trace cargo run --bin grpc-server

using docker:

docker build -t appflowy-grpc .
docker run -d -p 50051:50051 --name appflowy appflowy-grpc

Feature Preview

Screencast.2023-04-11.01.34.08.mp4

PR Checklist

  • My code adheres to the AppFlowy Style Guide
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

@appflowy
Copy link
Contributor

@abichinger Nice try! That is a new way to passthrough the data to the backend.

I am not sure is it work on mobile platform too and it seems like FFI is faster than gRPC.

@abichinger
Copy link
Contributor Author

Thanks!

According to https://pub.dev/packages/grpc all platforms are supported.
It is certainly slower than FFI, but gRPC enables the backend to be hosted on a cloud server.

@Xazin
Copy link
Collaborator

Xazin commented Apr 11, 2023

Thanks!

According to https://pub.dev/packages/grpc all platforms are supported. It is certainly slower than FFI, but gRPC enables the backend to be hosted on a cloud server.

Except Web (At least without grpc-web) - It's weird why it's not in supported platforms if they have support for it.

@appflowy
Copy link
Contributor

Thanks!

According to https://pub.dev/packages/grpc all platforms are supported. It is certainly slower than FFI, but gRPC enables the backend to be hosted on a cloud server.

Multiple AppFlowy instances can share the same backend that hosts on the cloud. Correct me if I was wrong

@abichinger
Copy link
Contributor Author

Yes that should be possible. (Haven't tested it yet)
I suspect there could be some problems if multiple AppFlowy instances try to access the backend simultaneously, because the backend isn't stateless.

@appflowy
Copy link
Contributor

Yes that should be possible. (Haven't tested it yet) I suspect there could be some problems if multiple AppFlowy instances try to access the backend simultaneously, because the backend isn't stateless.

Yep, each instance of the backend is belonging to a user.

@appflowy
Copy link
Contributor

@abichinger I am going to close this issue. Maybe we can reopen it in the future.

@appflowy appflowy closed this May 25, 2023
@silvergasp silvergasp mentioned this pull request Oct 27, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants