{"id":14968076,"url":"https://github.com/cr-org/supernova","last_synced_at":"2025-10-26T00:31:01.765Z","repository":{"id":56879494,"uuid":"286854952","full_name":"cr-org/supernova","owner":"cr-org","description":":milky_way: Apache Pulsar client for Haskell","archived":false,"fork":false,"pushed_at":"2020-10-23T14:09:02.000Z","size":300,"stargazers_count":38,"open_issues_count":2,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-31T12:51:22.698Z","etag":null,"topics":["apache-pulsar","haskell","nix"],"latest_commit_sha":null,"homepage":"http://hackage.haskell.org/package/supernova","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cr-org.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}},"created_at":"2020-08-11T21:50:54.000Z","updated_at":"2024-04-16T03:36:25.000Z","dependencies_parsed_at":"2022-08-20T23:10:52.799Z","dependency_job_id":null,"html_url":"https://github.com/cr-org/supernova","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr-org%2Fsupernova","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr-org%2Fsupernova/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr-org%2Fsupernova/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr-org%2Fsupernova/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cr-org","download_url":"https://codeload.github.com/cr-org/supernova/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238229940,"owners_count":19437723,"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":["apache-pulsar","haskell","nix"],"created_at":"2024-09-24T13:39:12.678Z","updated_at":"2025-10-26T00:30:54.257Z","avatar_url":"https://github.com/cr-org.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"supernova\n=========\n\n[![CI Status](https://github.com/cr-org/supernova/workflows/Haskell%20CI/badge.svg)](https://github.com/cr-org/supernova/actions)\n\n⚠️  **it is still very much under development 🚧 so use it at your own risk** ⚠️\n\nA *supernova* is a powerful and luminous stellar explosion. This transient astronomical event occurs during the last evolutionary stages of a massive star or when a white dwarf is triggered into runaway nuclear fusion. The original object, called the progenitor, either collapses to a [neutron](https://github.com/cr-org/neutron) star or black hole, or is completely destroyed. The peak optical luminosity of a supernova can be comparable to that of an entire galaxy before fading over several weeks or months.\n\n[![supernova](https://www.jpl.nasa.gov/spaceimages/images/largesize/PIA22352_hires.jpg \"Kepler Beyond Planets: Finding Exploding Stars (Type Ia Supernova from a White Dwarf Stealing Matter)\")](https://www.jpl.nasa.gov/spaceimages/details.php?id=PIA22352)\n\n### Quick Start\n\nThe example located in `test/Main.hs` showcases a consumer \u0026 producer running concurrently (needs the `async` library).\n\n```haskell\nmain :: IO ()\nmain = runPulsar conn $ do\n  c \u003c- newConsumer topic sub\n  p \u003c- newProducer topic\n  liftIO $ program c p\n\nconn :: PulsarConnection\nconn = connect defaultConnectData\n\ntopic :: Topic\ntopic = defaultTopic \"app\"\n\nsub :: Subscription\nsub = Subscription Exclusive \"test-sub\"\n\nprogram :: Consumer IO -\u003e Producer IO -\u003e IO ()\nprogram Consumer {..} Producer {..} =\n  let c = fetch \u003e\u003e= \\(Message i m) -\u003e msgDecoder m \u003e\u003e ack i \u003e\u003e c\n      p = sleep 3 \u003e\u003e traverse_ send messages \u003e\u003e p\n  in  concurrently_ c p\n```\n\nA `Message` contains a `MessageID` you need for `ack`ing and a payload defined as a lazy `ByteString`.\n\n\u003e Note that we wait a few seconds before publishing a message to make sure the consumer is already subscribed. Otherwise, it might miss some messages.\n\nRun it with the following command:\n\n```shell\ncabal new-run supernova-tests\n```\n\nBy default, it logs to the standard output in DEBUG level. You can change it by suppling `LogOptions` to the alternative function `runPulsar'`.\n\n```haskell\nrunPulsar' :: LogOptions -\u003e PulsarConnection -\u003e Pulsar a -\u003e IO ()\n```\n\n### Streaming\n\nSince both consumers and producers operate on any `MonadIO m`, we could leverage some streaming libraries. Here's the same example using [streamly](https://hackage.haskell.org/package/streamly).\n\n```haskell\nimport           Streamly\nimport qualified Streamly.Prelude              as S\n\nprogram :: Consumer IO -\u003e Producer IO -\u003e IO ()\nprogram Consumer {..} Producer {..} =\n  let c = fetch \u003e\u003e= \\(Message i m) -\u003e msgDecoder m \u003e\u003e ack i \u003e\u003e c\n      p = sleep 3 \u003e\u003e traverse_ send messages \u003e\u003e p\n  in  S.drain . asyncly . maxThreads 10 $ S.yieldM c \u003c\u003e S.yieldM p\n```\n\n### Development\n\nIt is recommended to use [Cachix](https://app.cachix.org/cache/hpulsar) to reduce the compilation time.\n\n```shell\nnix-build\n```\n\nOr within a Nix shell (run `nix-shell` at the project's root).\n\n```shell\ncabal new-build\n```\n\n#### Generate Hackage tarball\n\n```shell\ncabal new-sdist\n```\n\n#### Upload documentation\n\n```shell\ncabal new-haddock --haddock-for-hackage --enable-doc\ncabal upload -d dist-newstyle/supernova-0.0.2-docs.tar.gz --publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr-org%2Fsupernova","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcr-org%2Fsupernova","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr-org%2Fsupernova/lists"}