Skip to main content

Service Proxy – eigr/massa

Clone the repository​

To get started with the massa proxy, first clone the project from Github

git clone


> cd massa
> mix local.rebar --force
> mix local.hex --force
> mix deps.get

Run the Action TCK​

As an explanatory example, we will run the Action TCK with the eigr/massa proxy and the Go implementation.

                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    
β”Œβ”€β”€β”€β”€β–Άβ”‚PORT 9001β”‚ β”Œβ”€β”€β”€β–Άβ”‚PORT 8080β”‚
╔════════════════════╗ β”‚ ╔╩─────────╩═════════╗ β”‚ ╔╩─────────╩═══════════════════╗
β•‘ β•‘ β”‚ β•‘ β•‘ β”‚ β•‘ TCK function image β•‘
β•‘ grpcurl β• β”€β”€β”€β”˜ β•‘ eigr/massa proxy β• β”€β”€β”˜ β•‘ β•‘
β•‘ β•‘ β•‘ β•‘ β•‘ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
> cd apps/massa_proxy
> mix deps.get && mix format && mix compile
> iex --name [email protected] -S mix
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[debug]:Loading config user_function_host with value
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[debug]:Loading config user_function_port with value 8080
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[debug]:Loading config user_function_sock_addr with value /var/run/cloudstate.sock
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[debug]:Loading config user_function_uds_enable with value false
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[info]: HTTP Server started on port 9001
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[info]: Cluster Strategy
2021-08-10 16:41:47.723 [[email protected]]:[pid=<0.591.0> ]:[debug]:Cluster topology [proxy: [strategy: Cluster.Strategy.Gossip]]
2021-08-10 16:41:47.726 [[email protected]]:[pid=<0.709.0> ]:[debug]:Registry Node :"[email protected]" joining with Node :"[email protected]"
2021-08-10 16:41:47.726 [[email protected]]:[pid=<0.712.0> ]:[info]: Starting Horde.RegistryImpl with name MassaProxy.GlobalRegistry
2021-08-10 16:41:47.726 [[email protected]]:[pid=<0.713.0> ]:[debug]:Supervisor Node :"[email protected]" joining with Node :"[email protected]"
2021-08-10 16:41:47.726 [[email protected]]:[pid=<0.716.0> ]:[info]: Starting Horde.DynamicSupervisorImpl with name MassaProxy.GlobalSupervisor
2021-08-10 16:41:47.728 [[email protected]]:[pid=<0.729.0> ]:[debug]:Initializing Entity Registry with state []
2021-08-10 16:41:47.728 [[email protected]]:[pid=<0.730.0> ]:[debug]:Cache State: [cache_name: :cached_servers]
2021-08-10 16:41:47.728 [[email protected]]:[pid=<0.731.0> ]:[debug]:Cache State: [cache_name: :reflection_cache]
Interactive Elixir (1.12.2) - press Ctrl+C to exit (type h() ENTER for help)
iex([email protected])1> 2021-08-10 16:41:47.778 [[email protected]]:[pid=<0.732.0> ]:[info]: Starting Elixir.MassaProxy.Protocol.Discovery.Manager on target function address tcp://

Run the Action TCK Image​

To get started with development one can start one of the TCK images.

> docker run -it --rm -p 8080:8080 
2021/08/10 14:54:37 Received discovery call from sidecar [massa-proxy 0.1.0] supporting Cloudstate 1.1
2021/08/10 14:54:37 Responding with: service_name:"cloudstate.tck.model.EventSourcedTckModel" service_version:"0.2.0" service_runtime:"go1.14.4 linux/amd64" support_library_name:"cloudstate-go-support" support_library_version:"0.2.0" protocol_minor_version:2

Right after the starting the TCK image has been started, the massa proxy will discover the new entity:

2021-08-10 16:54:38.918 [[email protected]]:[pid=<0.732.0> ]:[debug]:Service compilation finish!
2021-08-10 16:54:38.919 [[email protected]]:[pid=<0.732.0> ]:[debug]:Endpoint Definition:
defmodule Massa.Server.Grpc.ProxyEndpoint do
@moduledoc false
use GRPC.Endpoint


services = [
2021-08-10 16:54:38.932 [[email protected]]:[pid=<0.732.0> ]:[debug]:Endpoint compilation finish!
2021-08-10 16:54:38.932 [[email protected]]:[pid=<0.732.0> ]:[info]: Starting gRPC Server...
2021-08-10 16:54:38.933 [[email protected]]:[pid=<0.2710.0> ]:[info]: Running Massa.Server.Grpc.ProxyEndpoint with Cowboy using
2021-08-10 16:54:38.933 [[email protected]]:[pid=<0.732.0> ]:[info]: Started gRPC Server in 1.558888ms

It will detect registered services and compile the gRPC stubs needed to serve services. Now, a tool like grpcurl can be used to issue a service request against the proxied service:

> grpcurl -d '{"groups": {"steps": [{"reply":{"message":"The north face was first climbed on July 24, 1938"}}]}}' --plaintext localhost:9000 cloudstate.tck.model.action.ActionTckModel.ProcessUnary
"message": "\\u00123\n1The north face was first climbed on July 24, 1938"