AvroRPC

AvroRPC is an Elixir library for making RPC calls using the Avro protocol specification. Currently, AvroRPC wraps functionality from both the eavro and ex_avro libraries and provides a unified client implementation for managing connections and calling methods across multiple AvroRPC services.

Installation

If available in Hex, the package can be installed by adding both avro_rpc and eavro to your list of dependencies in mix.exs:

def deps do
  [
    {:avro_rpc, "~> 0.1.0"},
    {:eavro, git: "https://github.com/sifoxdevteam/eavro.git", tag: "v0.0.3"}
  ]
end

You will also need to ensure that avro_rpc is started before your application:

def application do
  [
    applications: [
      :avro_rpc
    ]
  ]
end

Configuration

AvroRPC currently only provides an implementation for consuming AvroRPC endpoints as a client. When your application starts, AvroRPC will attempt to connect to each service specified in your application's configuration.

You can configure AvroRPC in your mix.exs file, like so:

config :avro_rpc,
  services: [
    %{
      name: :service_1,
      hostname: "localhost",
      port: 9015,
      protocol: "./test/data/avro.json"
    },
    %{
      name: :service_2,
      hostname: "localhost",
      port: 9000,
      protocol: "./test/data/customer_profile.json"
    }
  ]

AvroRPC will open a connection for each item in the services list of your config.

Each individual element in the services list must be a Map containing the following fields:

Usage

AvroRPC currently only exposes one public function: AvroRPC.Client.call/3, which is used to call a method on a specific service, and pass in a list of arguments to that method.

For example, if you have a service named :test_server, with a hello method, you'd call it like so:

{:ok, response} = AvroRPC.Client.call(:test_server, :hello, ["world"])

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/avro_rpc.