{"id":32171598,"url":"https://github.com/blueshift-labs/neutron","last_synced_at":"2025-10-21T17:54:12.280Z","repository":{"id":54194278,"uuid":"249089617","full_name":"blueshift-labs/neutron","owner":"blueshift-labs","description":"Apache Pulsar client based on C nifs","archived":false,"fork":false,"pushed_at":"2024-08-06T03:29:29.000Z","size":97,"stargazers_count":3,"open_issues_count":4,"forks_count":2,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-09-15T12:00:08.627Z","etag":null,"topics":["apache-pulsar","pulsar","pulsar-client"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/neutron","language":"C","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/blueshift-labs.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":"2020-03-22T01:07:34.000Z","updated_at":"2024-08-06T03:29:33.000Z","dependencies_parsed_at":"2024-08-06T06:30:01.557Z","dependency_job_id":null,"html_url":"https://github.com/blueshift-labs/neutron","commit_stats":{"total_commits":64,"total_committers":6,"mean_commits":"10.666666666666666","dds":0.546875,"last_synced_commit":"895061b6b0d912eeb823e68fbd7c862947d4a666"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/blueshift-labs/neutron","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blueshift-labs%2Fneutron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blueshift-labs%2Fneutron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blueshift-labs%2Fneutron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blueshift-labs%2Fneutron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blueshift-labs","download_url":"https://codeload.github.com/blueshift-labs/neutron/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blueshift-labs%2Fneutron/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280308477,"owners_count":26308492,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["apache-pulsar","pulsar","pulsar-client"],"created_at":"2025-10-21T17:54:07.448Z","updated_at":"2025-10-21T17:54:12.274Z","avatar_url":"https://github.com/blueshift-labs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neutron\n\n- A simple apache pulsar client using their C/C++ client (2.6.0) and nifs.\n- The persistent_term API is being used so this requires OTP 21+ hence elixir 1.10+.\n- Caution `ack_all` doesn't work as expected with `shared` subscription.\n\nhttps://pulsar.apache.org/docs/en/client-libraries-cpp/\nhttps://pulsar.apache.org/api/cpp/\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:neutron, \"~\u003e 0.2\"}\n  ]\nend\n```\n\n### Configure\nIn your configs:\n\n```elixir\nconfig :neutron,\n  url: \"pulsar://localhost:6650\", # this is the default value and ideally should be set\n  thread_count: 4 # this is optional and defaults to System.schedulers_online()\n```\n\nThe above is used for the pulsar client configuration. There is 1 global client that's stored using persistent_term. The thread count is used for the pulsar client IO Threads and Message Listener Threads\n\n\n### Consuming\nHow to start a consumer under neutron's supervisor tree:\n\n```elixir\ndefmodule ConsumerCallback do\n  @behaviour Neutron.PulsarConsumerCallback\n\n  @impl true\n  def handle_message(msg) do\n    IO.inspect(msg)\n    :ack\n  end\nend\n\nNeutron.start_consumer([callback_module: ConsumerCallback, consumer_type: :shared, topic: \"my-topic\", subscription: \"my-subscription\"])\n```\n\nSee the `start_consumer` documentation for more information. The above shows all the default values being used minus callback_module which defaults to a module which shouldn't exist and is required.\n\n### Producing\nHow to do an async produce. Ideally the producer created by the first call should be put under a supervisor tree or threaded through your program. Use create_managed_async_producer and genserver call by name or tuple if you want to do otherwise. The sync produce API is also available but is also less efficient as a producer is created in the nif per call\n\n```elixir\ndefmodule DeliverCallback do\n  @behaviour Neutron.PulsarAsyncProducerCallback\n\n  @impl true\n  def handle_delivery(res) do\n    case res do\n      {:ok, _msg_id_string, _msg} -\u003e IO.inspect \"successful produce\"\n      {:error, _msg_id_string, _msg} -\u003e IO.inspect \"failed produce\"\n    end\n  end\nend\n\n# async produce\n{:ok, pid} = Neutron.create_async_producer(\"my-topic\", DeliverCallback)\n:ok = Neutron.async_produce(pid, \"hello message\")\n\n# sync produce\n:ok = Neutron.sync_produce(\"my-topic\", \"hello message redux\")\n```\n\nCompression is still not supported for producing but will likely be added in a later version.\n\n\n### Docker\n- For debian-based packages `cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev libprotobuf-dev protobuf-compiler libboost-all-dev libjsoncpp-dev git build-essential google-mock libgtest-dev` are required as dependencies. I also noticed an issue with the pulsar C/C++ library and using alpine linux.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblueshift-labs%2Fneutron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblueshift-labs%2Fneutron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblueshift-labs%2Fneutron/lists"}