{"id":42684806,"url":"https://github.com/codepr/pluribus","last_synced_at":"2026-01-29T12:08:00.135Z","repository":{"id":322977225,"uuid":"1087424458","full_name":"codepr/pluribus","owner":"codepr","description":"Small library to simplify testing of scalable platforms, e.g. MQTT platforms for IoT, it allows to define custom behaviors and deploy virtual devices in a cluster of nodes.","archived":false,"fork":false,"pushed_at":"2025-11-07T10:22:34.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-07T12:13:52.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codepr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-31T22:17:28.000Z","updated_at":"2025-11-07T10:22:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/codepr/pluribus","commit_stats":null,"previous_names":["codepr/pluribus"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/codepr/pluribus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepr%2Fpluribus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepr%2Fpluribus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepr%2Fpluribus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepr%2Fpluribus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codepr","download_url":"https://codeload.github.com/codepr/pluribus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepr%2Fpluribus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28877123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-29T12:07:58.240Z","updated_at":"2026-01-29T12:08:00.127Z","avatar_url":"https://github.com/codepr.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pluribus\n\nSmall library to simplify testing of scalable platforms, e.g. MQTT platforms\nfor IoT, it allows to define custom behaviors and deploy virtual devices in a\ncluster of nodes.\n\nOld buried library I wrote ages ago to test out an IoT infra, resurrected and\nre-factored a little.\n\n## Roadmap\n\nCurrently very rough and ready stage, next mid / long term improvements:\n\n- Better device lifecycle management (e.g. `on_start`, `on_stop` callbacks etc)\n- Fleet scaling\n- Load strategies (e.g. wave, random burts, ramp up etc)\n- Network issues simulation\n- Automated scenarios in a test-like DSL\n- Dashboard to observe the fleets, load etc\n- Pre-built aggregators (e.g. generic MQTT, HTTP / REST, FIX etc)\n\n## Quickstart\n\nDeploy a device in the cluster. The device process will be started in any node of\nthe cluster.\n\nAllowed option entries:\n\n- `device_id` represents the ID of a virtual device, if not specified a random one\n  will be generated\n- `aggregator_module` the logic for publishing telemetries produced by the virtual\n  device, may be any I/O, e.g writing to a DB, to a broker etc.\n  By default if not specified uses the `ConsoleTelemetryAggregator` or the one\n  defined in the config module.\n\n```elixir\niex\u003e Pluribus.deploy_device(Pluribus.VirtualDevices.GenericVirtualDevice)\n{:ok, \u003c123\u003e}\n```\n\n### Custom aggregator module\n\nThe following example shows how to define a MQTT (uses [emqtt](https://github.com/emqx/emqtt))\nbased custom device and aggregator\n\n```elixir\ndefmodule MQTTTelemetryAggregator do\n  use GenServer\n  @behaviour Pluribus.TelemetryAggregator\n\n  def start_link(args) do\n    GenServer.start_link(__MODULE__, args)\n  end\n\n  # --- TELEMETRY AGGREGATOR CALLBACKS ---\n\n  @impl true\n  def publish_telemetry(telemetry) do\n    payload = :erlang.term_to_binary(message)\n    GenServer.cast(__MODULE__, {:publish, payload})\n  end\n\n  # --- GENSERVER CALLBACKS ---\n\n  @impl true\n  def init(args) do\n    {:ok, pid} = :emqtt.start_link(args)\n    {:ok, %{pid: pid}, {:continue, :start_emqtt}}\n  end\n\n  @impl true\n  def handle_continue(:start_emqtt, %{pid: pid} = state) do\n    {:ok, _} = :emqtt.connect(pid)\n    emqtt_opts = Application.get_env(:aggregator_module, :emqtt)\n    clientid = emqtt_opts[:clientid]\n    report_topic = \"reports/\\#{clientid}/temperature\"\n    {:noreply, %{state | report_topic: report_topic}}\n  end\n\n  @impl true\n  def handle_cast({:publish, payload}, state) do\n    %{pid: pid, report_topic: report_topic} = state\n    :emqtt.publish(pid, report_topic, payload)\n    {:noreply, state}\n  end\nend\n```\n\n### Custom virtual device\n\nHandles some state and updates from subscriptions\n\n```elixir\ndefmodule MQTTVirtualDevice do\n  use GenServer\n  @behaviour Pluribus.VirtualDeviceState\n\n  def start_link(args) do\n    GenServer.start_link(__MODULE__, args)\n  end\n\n  # --- GENSERVER CALLBACKS ---\n\n  @impl true\n  def init(args) do\n    {:ok, pid} = :emqtt.start_link(args)\n    {:ok, %{pid: pid}, {:continue, :start_emqtt}}\n  end\n\n  @impl true\n  def handle_continue(:start_emqtt, %{pid: pid} = state) do\n    {:ok, _} = :emqtt.connect(pid)\n    emqtt_opts = Application.get_env(:virtual_device, :emqtt)\n    clientid = emqtt_opts[:clientid]\n    metrics_topic = \"metrics/\\#{clientid}/temperature\"\n    {:ok, _, _} = :emqtt.subscribe(pid, {\"metrics/\\#{clientid}/temperature\", 1})\n    {:noreply, %{state | metrics_topic: metrics_topic}}\n  end\n\n  @impl true\n  def handle_info({:publish, %{payload: payload}}, state) do\n    {:noreply, %{state | metrics: :erlang.binary_to_term(payload)}}\n  end\n\n  @impl true\n  def handle_call(:get_metrics, _from, %{metrics: metrics} = state) do\n    {:reply, metrics, state}\n  end\n\n  # --- VIRTUAL DEVICE CALLBACKS ---\n\n  @impl true\n  def report_telemetry(state) do\n    metrics = get_metrics()\n    %{\n      device_id: state.id,\n      device_type: \"MQTT_Sensor\",\n      timestamp: System.os_time(:millisecond),\n      data: metrics\n    }\n  end\n\n  defp get_metrics do\n    GenServer.call(__MODULE__, :get_metrics)\n  end\nend\n```\n\n### Deploy an MQTT virtual device\n\n```elixir\niex\u003e Pluribus.deploy_device(MQTTVirtualDevice, aggregator_module: MQTTTelemetryAggregator)\n{:ok, \u003c123\u003e}\n```\n\n### Deploy an MQTT virtual device fleet\n\n```elixir\niex\u003e Pluribus.deploy_fleet([\n            %{\n                device_id: \"fleet_1_1\",\n                logic_module: MQTTVirtualDevice,\n                aggregator_module: MQTTTelemetryAggregator,\n                opts: [{:clientid, \"fleet_1_1\"}]\n            },\n            %{\n                device_id: \"fleet_1_2\",\n                logic_module: MQTTVirtualDevice,\n                aggregator_module: MQTTTelemetryAggregator,\n                opts: [{:clientid, \"fleet_1_2\"}]\n            },\n            %{\n                device_id: \"fleet_1_3\",\n                logic_module: MQTTVirtualDevice,\n                aggregator_module: MQTTTelemetryAggregator,\n                opts: [{:clientid, \"fleet_1_3\"}]\n            },\n          ])\n```\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `pluribus` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:pluribus, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at \u003chttps://hexdocs.pm/pluribus\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepr%2Fpluribus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodepr%2Fpluribus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepr%2Fpluribus/lists"}