{"id":15667905,"url":"https://github.com/rupurt/schoolbus","last_synced_at":"2025-05-01T01:52:22.714Z","repository":{"id":40550809,"uuid":"238971261","full_name":"rupurt/schoolbus","owner":"rupurt","description":"Manage one or more PubSub instances using the Elixir registry","archived":false,"fork":false,"pushed_at":"2023-05-01T18:57:40.000Z","size":64,"stargazers_count":19,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-01T01:52:07.763Z","etag":null,"topics":["elixir","pubsub"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rupurt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-02-07T16:21:26.000Z","updated_at":"2025-02-05T17:43:11.000Z","dependencies_parsed_at":"2024-10-23T09:33:22.013Z","dependency_job_id":"e8e6d783-324b-4a3e-9b20-632f5b52ff2d","html_url":"https://github.com/rupurt/schoolbus","commit_stats":{"total_commits":42,"total_committers":4,"mean_commits":10.5,"dds":0.6666666666666667,"last_synced_commit":"0bb9c465fe4ce001d4f90d7d9b2068614fd2a38a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupurt%2Fschoolbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupurt%2Fschoolbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupurt%2Fschoolbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupurt%2Fschoolbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rupurt","download_url":"https://codeload.github.com/rupurt/schoolbus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251810899,"owners_count":21647626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["elixir","pubsub"],"created_at":"2024-10-03T14:05:48.677Z","updated_at":"2025-05-01T01:52:22.688Z","avatar_url":"https://github.com/rupurt.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schoolbus\n[![Build Status](https://github.com/rupurt/schoolbus/workflows/test/badge.svg?branch=main)](https://github.com/rupurt/schoolbus/actions?query=workflow%3Atest)\n[![hex.pm version](https://img.shields.io/hexpm/v/schoolbus.svg?style=flat)](https://hex.pm/packages/schoolbus)\n\nManage one or more PubSub instances using the Elixir registry\n\n## Installation\n\n`schoolbus` requires Elixir 1.9+ \u0026 Erlang/OTP 21+\n\nAdd the `schoolbus` package to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:schoolbus, \"~\u003e 0.0.3\"}]\nend\n```\n\n## Usage\n\n### The default single bus\n\nStart the bus\n\n```elixir\niex(1)\u003e {:ok, _bus} = Schoolbus.start_link([])\n{:ok, #PID\u003c0.212.0\u003e}\n```\n\nRegister a topic\n\n```elixir\niex(2)\u003e Schoolbus.register(:games)\n:ok\n```\n\nRegister a namespaced topic\n\n```elixir\niex(3)\u003e Schoolbus.register({:songs, :diplo})\n:ok\niex(4)\u003e Schoolbus.register({:songs, :tiesto})\n:ok\n```\n\nSubscribe to a registered topic\n\n```elixir\niex(3)\u003e Schoolbus.subscribers()\n[]\niex(4)\u003e Schoolbus.subscribe(:games)\n{:ok, [:games]}\niex(5)\u003e self()\n#PID\u003c0.208.0\u003e\niex(6)\u003e Schoolbus.subscribers()\n[games: #PID\u003c0.208.0\u003e]\n```\n\nSubscribe to all topics within a namespace\n\n```elixir\niex(7)\u003e Schoolbus.subscribers()\n[games: #PID\u003c0.208.0\u003e]\niex(8)\u003e Schoolbus.subscribe({:songs, \"*\"})\n{:ok, [songs: :diplo, songs: :tiesto]}\niex(9)\u003e self()\n#PID\u003c0.208.0\u003e\niex(10)\u003e Schoolbus.subscribers()\n[\n  {{:songs, :tiesto}, #PID\u003c0.208.0\u003e},\n  {{:songs, :diplo}, #PID\u003c0.208.0\u003e},\n  {:games, #PID\u003c0.208.0\u003e}\n]\n```\n\nBroadcast a topic to all subscribers\n\n```elixir\niex(11)\u003e flush\n:ok\niex(12)\u003e Schoolbus.broadcast(:games, :uno)\n:ok\niex(13)\u003e flush\n:uno\n:ok\n```\n\n### Multiple buses\n\nDefine two buses\n\n`BusA`:\n\n```elixir\niex(1)\u003e defmodule BusA do\n...(1)\u003e   use Schoolbus.Bus\n...(1)\u003e end\n{:module, BusA,\n \u003c\u003c70, 79, 82, 49, 0, 0, 16, 196, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 2, 32,\n   0, 0, 0, 53, 11, 69, 108, 105, 120, 105, 114, 46, 66, 117, 115, 65, 8, 95,\n   95, 105, 110, 102, 111, 95, 95, 7, 99, ...\u003e\u003e, {:registered_topics, 0}}\n```\n\n`BusB`:\n\n```elixir\niex(2)\u003e defmodule BusB do\n...(2)\u003e   use Schoolbus.Bus\n...(2)\u003e end\n{:module, BusB,\n \u003c\u003c70, 79, 82, 49, 0, 0, 16, 200, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 2, 32,\n   0, 0, 0, 53, 11, 69, 108, 105, 120, 105, 114, 46, 66, 117, 115, 66, 8, 95,\n   95, 105, 110, 102, 111, 95, 95, 7, 99, ...\u003e\u003e, {:registered_topics, 0}}\n```\n\nStart the two buses\n\n```elixir\niex(1)\u003e {:ok, _bus_a} = BusA.start_link([])\n{:ok, #PID\u003c0.210.0\u003e}\niex(2)\u003e {:ok, _bus_b} = BusB.start_link([])\n{:ok, #PID\u003c0.220.0\u003e}\n```\n\nRegister the topics\n\n```elixir\niex(3)\u003e BusA.register(:bus_a_topic)\n:ok\niex(4)\u003e BusB.register(:bus_b_topic)\n:ok\n```\n\nSubscribe to a registered topic\n\n```elixir\niex(5)\u003e BusA.subscribers()\n[]\niex(6)\u003e BusB.subscribers()\n[]\niex(7)\u003e BusA.subscribe(:bus_a_topic)\n{:ok, [:bus_a_topic]}\niex(8)\u003e BusB.subscribe(:bus_b_topic)\n{:ok, [:bus_b_topic]}\niex(9)\u003e self()\n#PID\u003c0.208.0\u003e\niex(10)\u003e BusA.subscribers()\n[bus_a_topic: #PID\u003c0.208.0\u003e]\niex(11)\u003e BusB.subscribers()\n[bus_b_topic: #PID\u003c0.208.0\u003e]\n```\n\nBroadcast a topic to all subscribers\n\n```elixir\niex(12)\u003e flush\n:ok\niex(13)\u003e BusA.broadcast(:bus_a_topic, :my_message_a)\n:ok\niex(14)\u003e flush\n:my_message_a\n:ok\niex(15)\u003e BusB.broadcast(:bus_a_topic, :my_message_b)\n:ok\niex(16)\u003e flush\n:my_message_b\n:ok\n```\n\n## Authors\n\n* Alex Kwiatkowski - alex+git@rival-studios.com\n\n## License\n\n`schoolbus` is released under the [MIT license](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupurt%2Fschoolbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frupurt%2Fschoolbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupurt%2Fschoolbus/lists"}