All Projects → cr-org → supernova

cr-org / supernova

Licence: Apache-2.0 license
🌌 Apache Pulsar client for Haskell

Programming Languages

haskell
3896 projects
Nix
1067 projects

Projects that are alternatives of or similar to supernova

nixcfg
My nix configuration(s), using flakes. It's my laptop, it's my servers, it's my everything, in code.
Stars: ✭ 44 (+25.71%)
Mutual labels:  nix
easy-dhall-nix
Derivations for easily downloading Dhall binaries and putting them to use.
Stars: ✭ 22 (-37.14%)
Mutual labels:  nix
tgip-cn
TGIP-CN (Thank God Its Pulsar) is a weekly live video streaming about Apache Pulsar in Chinese.
Stars: ✭ 96 (+174.29%)
Mutual labels:  apache-pulsar
nix-unstable-installer
A place to host Nix unstable releases.
Stars: ✭ 96 (+174.29%)
Mutual labels:  nix
system
The system configuration of a professional yak shaver
Stars: ✭ 42 (+20%)
Mutual labels:  nix
idris2-pkgs
An unofficial Idris2 package repository for Nix
Stars: ✭ 32 (-8.57%)
Mutual labels:  nix
piston-cli
Universal shell supporting code highlighting, files, and interpretation without the need to download a language.
Stars: ✭ 43 (+22.86%)
Mutual labels:  nix
nix-rice
A library to functionally define your configuration and theme (rice) with Nix
Stars: ✭ 43 (+22.86%)
Mutual labels:  nix
yants
Yet Another Nix Type System | Source has moved to https://git.tazj.in/tree/nix/yants
Stars: ✭ 35 (+0%)
Mutual labels:  nix
nixdots
I have no idea what the hell I'm doing
Stars: ✭ 46 (+31.43%)
Mutual labels:  nix
emacs2nix
Automatically generate Nix expressions for Emacs packages
Stars: ✭ 23 (-34.29%)
Mutual labels:  nix
nix-env-selector
Allows switch environment for Visual Studio Code using Nix Package Manager.
Stars: ✭ 154 (+340%)
Mutual labels:  nix
denxi
Denxi is a programming model for distributing data. It reduces the cost of producing package managers, storefronts, operating systems, and CI/CD systems.
Stars: ✭ 65 (+85.71%)
Mutual labels:  nix
FullstackRustDemo
Novelty website + bucket questions implementation.
Stars: ✭ 40 (+14.29%)
Mutual labels:  nix
base16.nix
Quickly theme programs in your favourite base16 colorscheme
Stars: ✭ 61 (+74.29%)
Mutual labels:  nix
dotnix
nix stuff
Stars: ✭ 27 (-22.86%)
Mutual labels:  nix
dotfiles
🏠
Stars: ✭ 53 (+51.43%)
Mutual labels:  nix
flake-nimble
Nimble packages Nix flake [maintainer=@ehmry]
Stars: ✭ 26 (-25.71%)
Mutual labels:  nix
dotfiles
dotfiles repository
Stars: ✭ 15 (-57.14%)
Mutual labels:  nix
dotfiles
My dotfiles for Bash/Zsh, Vim/Neovim, Doom Emacs, tmux, Git, terminal emulators, JupyterLab, aria2, mpv, Nix and Homebrew
Stars: ✭ 149 (+325.71%)
Mutual labels:  nix

supernova

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.

supernova

Quick Start

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

main :: IO ()
main = runPulsar conn $ do
  c <- newConsumer topic sub
  p <- newProducer topic
  liftIO $ program c p

conn :: PulsarConnection
conn = connect defaultConnectData

topic :: Topic
topic = defaultTopic "app"

sub :: Subscription
sub = Subscription Exclusive "test-sub"

program :: Consumer IO -> Producer IO -> IO ()
program Consumer {..} Producer {..} =
  let c = fetch >>= \(Message i m) -> msgDecoder m >> ack i >> c
      p = sleep 3 >> traverse_ send messages >> p
  in  concurrently_ c p

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

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.

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 to the alternative function runPulsar'.

runPulsar' :: LogOptions -> PulsarConnection -> Pulsar a -> IO ()

Streaming

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

program :: Consumer IO -> Producer IO -> IO ()
program Consumer {..} Producer {..} =
  let c = fetch >>= \(Message i m) -> msgDecoder m >> ack i >> c
      p = sleep 3 >> traverse_ send messages >> p
  in  S.drain . asyncly . maxThreads 10 $ S.yieldM c <> S.yieldM p

Development

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

nix-build

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

cabal new-build

Generate Hackage tarball

cabal new-sdist

Upload documentation

cabal new-haddock --haddock-for-hackage --enable-doc
cabal upload -d dist-newstyle/supernova-0.0.2-docs.tar.gz --publish
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].