Skip to main content

RPC icon Sylk Method (RPC)

In Sylk, a method resource represents an RPC (Remote Procedure Call) method that can be invoked by a client to request a specific action from the server. A method resource defines the input and output messages that the RPC method takes and returns, respectively.

In Sylk CLI, you can define custom method resource types using the

# The following command generates an RPC (Remote Procedure Call)
# function for a specific service method.
sylk generate rpc foo.bar.v1.SomeService.GetSomething

#  foo . bar . v1 . SomeService . GetSomething
# | | | | |
# | | | | └─ The name of the method inside the service.
# | | | └─ The name of the service (collection of related methods).
# | | └─ The version of the package.
# | └─ The namespace of the package (logical grouping).
# └─ Root namespace.

Each method resource is associated with a service resource and can be grouped into one or more packages. The method resource includes the following information:

  • Name: the unique name of the method resource within the service resource
  • Request message type: the input message type that the method expects to receive as a parameter
  • Response message type: the output message type that the method returns as a result

Each method can be one of the available types listed below:

  1. Unary: In a Unary RPC, a client sends a single request to the server and gets a single response in return.

  2. Server Streaming: In a Server Streaming RPC, a client sends a single request to the server and the server responds with a stream of messages.

  3. Client Streaming: In a Client Streaming RPC, a client sends a stream of messages to the server and the server responds with a single response.

  4. Bidirectional Streaming: In a Bidirectional Streaming RPC, both the client and server send a stream of messages to each other.