supernova: Apache Pulsar client for Haskell

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Supernova is an Apache Pulsar client that implements the specified TCP protocol.

[Skip to Readme]


Versions 0.0.1, 0.0.1, 0.0.2, 0.0.3
Change log None available
Dependencies base (>=4.13.0 && <4.14), bifunctor (>=0.1.0 && <0.2), binary (>=0.8.7 && <0.9), bytestring (>=0.10.10 && <0.11), crc32c (>=0.0.0 && <0.1), exceptions (>=0.10.4 && <0.11), lens-family-core (>=2.0.0 && <2.1), logging (>=3.0.5 && <3.1), managed (>=1.0.7 && <1.1), network (>=3.1.2 && <3.2), proto-lens (>=0.7.0 && <0.8), proto-lens-runtime (>=0.7.0 && <0.8), text (>=1.2.4 && <1.3), unliftio (>=0.2.13 && <0.3) [details]
License Apache-2.0
Author Gabriel Volpe
Category Network
Home page
Bug tracker
Uploaded by gvolpe at 2020-08-26T15:13:50Z


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for supernova-0.0.1

[back to package description]


CI Status

⚠️ it is still very much under development 🚧 so use it at your own risk ⚠️

A 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 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.


Quick Start

The example located in test/Main.hs showcases a simple consumer and producer running concurrently (needs the async library).

main :: IO ()
main = runPulsar resources $ \(Consumer {..}, Producer {..}) ->
  let c = forever $ fetch >>= \(Message i m) -> msgDecoder m >> ack i
      p = forever $ sleep 5 >> traverse_ produce messages
  in  concurrently_ c p

resources :: Pulsar (Consumer IO, Producer IO)
resources = do
  ctx      <- connect defaultConnectData
  consumer <- newConsumer ctx topic "test-sub"
  producer <- newProducer ctx topic
  return (consumer, producer)

A Message contains a MessageID you need for acking and a payload defined as a lazy ByteString.

Run it with the following command:

cabal new-run supernova-tests

By default, it logs to the standard output in DEBUG level. You can change it by suppling LogOptions.

logOpts :: LogOptions
logOpts = LogOptions Info StdOut

runPulsar' logOpts resources


Since both consumers and producers operate on any MonadIO m, we could leverage some streaming libraries. Here's the same example using streamly.

import           Streamly
import qualified Streamly.Prelude              as S

main :: IO ()
main = runPulsar resources $ \(Consumer {..}, Producer {..}) ->
  let c = forever $ fetch >>= \(Message i p) -> msgDecoder p >> ack i
      p = forever $ sleep 5 >> traverse_ produce messages
  in  S.drain . asyncly . maxThreads 10 $ S.yieldM c <> S.yieldM p


It is recommended to use Cachix to reduce the compilation time.


Or within a Nix shell (run nix-shell at the project's root).

cabal new-build