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

1. Define Protocol Format Definitions #9

Closed
juanpedromoreno opened this issue Jun 20, 2017 · 1 comment
Closed

1. Define Protocol Format Definitions #9

juanpedromoreno opened this issue Jun 20, 2017 · 1 comment
Assignees

Comments

@juanpedromoreno
Copy link
Member

After discussing the best approach it makes sense to divide the RPC framework into three main building blocks. Protocols, Server, and Client.

This issue addresses some of the main concerns when defining the protocol piece.

  1. Protocols should be defined in a separate module to avoid server and client specific dependencies.
  2. Protocols will be defined as scala traits in code and will derive proto files automatically for other langs and frameworks to consume those. This will enable Freestyle microservices to be consumed from any lang that or framework that support codegen from proto file.
    The proposed protocol declaration for a service is as follows:
  @service
  trait Greeter {
    @rpc def sayHello(msg: MessageRequest): FS[MessageReply]
    @rpc def lotsOfReplies(msg: MessageRequest, observer: StreamObserver[MessageReply]): FS[Unit]
    @rpc def lotsOfGreetings(msg: StreamObserver[MessageReply]): FS[StreamObserver[MessageRequest]]
    @rpc def bidiHello(msg: StreamObserver[MessageReply]): FS[StreamObserver[MessageRequest]]
  }

  @message case class MessageRequest(name: String)
  @message case class MessageReply(message: String)

The service and messages definitions above will generate the following .protofiles

syntax = "proto3";

package freestyle.rpc.demo;

service Greeter {
    rpc SayHello (MessageRequest) returns (MessageReply) {}
    rpc LotsOfReplies(MessageRequest) returns (stream MessageReply) {}
    rpc LotsOfGreetings(stream MessageRequest) returns (MessageReply) {}
    rpc BidiHello(stream MessageRequest) returns (stream MessageReply) {}
}

message MessageRequest {
    string name = 1;
}

message MessageReply {
    string message = 1;
}
  1. The protocol module will also be responsible for including @free representations of the traits to be used in a process outside of RPC concerns. A special version of the abstract handler will also be generated containing the stubs necessary for Servers to be hydrated given a list of @service protocol types.
  2. Is not the responsibility of this module to generate any kind of server or client code and should remain decoupled from those concerns.
@juanpedromoreno
Copy link
Member Author

Superseded by #28 and #29

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

No branches or pull requests

2 participants