Skip to content

edenlabllc/kube_rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KubeRpc

Client-server library for erlang/elixir RPC microservices interactions. Can be used for avoid code duplication between microservices.

Features:

  • erlang native RPC usage
  • GenServer/call function for sending messages to remote processes
  • non blocking server queue
  • RPC retry calls in case of fail
  • health check support
  • k8s scaling support allowing to send messages to equal microservices from the same namespace

Server

Starts automatically with the application. Will create a separate async process for each RPC request to avoid long messages mailbox queue. Supports 2 ways of health check:

  • sync :ping
  • async :check

Client

Provides interface for calling the Server. Can retry RPC call up to 3 (configured value) times. Randomly chose a server among available erlang nodes in the cluster which match the basename pattern.

Installation

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

def deps do
  [
    {:kube_rpc, "~> 0.4.1"}
  ]
end

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

Usage

For server, just add library to project and connect it to the erlang cluster.

For client, create it for your application:

defmodule Core.Rpc.Worker do
  @moduledoc false

  use KubeRPC.Client, :core
end

and connect it to the erlang cluster. You are able to call any public function in any module on the server:

  alias Core.Rpc.Worker
  Worker.run("my_basename", MyBasename.RpcServer, :run, args)

"my_basename" - is the server basename which is the part of the erlang node name (before @)

MyBasename.RpcServer - module to call

:run - function to call

args - list of args to call the function with

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages