[central-exchange] very simple implementation using nanomsg

parent dc0df15d
Pipeline #6119 failed with stages
in 72 minutes and 15 seconds
{-|
Module : Main.hs
Description : Gargantext central exchange for async notifications
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE Strict #-}
module Main where
import Control.Concurrent (threadDelay)
import Control.Monad (join, mapM_)
import Data.ByteString.Char8 qualified as C
import Data.Text qualified as T
import Gargantext.Prelude
import Nanomsg
import Options.Applicative
data Command =
Server
| Client
parser :: Parser (IO ())
parser = subparser
( command "server" (info (pure gServer) idm)
<> command "client" (info (pure gClient) idm) )
main :: IO ()
main = join $ execParser (info parser idm)
gClient :: IO ()
gClient = do
withSocket Push $ \s -> do
_ <- connect s "tcp://localhost:5560"
let str = C.unwords (take 1000 $ repeat "hello")
C.putStrLn $ C.pack "sending: " <> (C.take 100 str)
replicateM_ 100 $
send s str
gServer :: IO ()
gServer = do
withSocket Pull $ \s -> do
_ <- bind s "tcp://*:5560"
forever $ do
putText "receiving"
r <- recv s
C.putStrLn $ C.take 100 r
-- r <- recv' s
-- -- putText $ T.pack $ C.unpack r
-- putText "..."
-- case r of
-- Nothing -> pure ()
-- Just r' -> C.putStrLn $ C.take 100 r'
-- threadDelay 1000000
-- withSocket Pub $ \s -> do
-- _ <- bind s "tcp://*:5560"
-- mapM_ (\num -> sendNumber s num) (cycle [1..1000000 :: Int])
-- where
-- sendNumber s number = do
-- threadDelay 1000 -- let's conserve some cycles
-- let numAsString = show number
-- send s (C.pack numAsString)
......@@ -166,6 +166,16 @@ source-repository-package
location: https://github.com/robstewart57/rdf4h.git
tag: 4fd2edf30c141600ffad6d730cc4c1c08a6dbce4
source-repository-package
type: git
location: https://github.com/garganscript/nanomsg-haskell
tag: 5e4e119881d81b8a8f77a79b3caaebb1bb304790
-- source-repository-package
-- type: git
-- location: https://github.com/jimenezrick/nng-haskell
-- tag: 31e52d7bc720e5fb9daf1c1e8bc1fd156d577af2
allow-older: *
allow-newer: *
......
......@@ -849,6 +849,27 @@ executable gargantext-upgrade
, postgresql-simple ^>= 0.6.4
, text ^>= 1.2.4.1
executable gargantext-central-exchange
import:
defaults
main-is: Main.hs
other-modules:
Paths_gargantext
hs-source-dirs:
bin/gargantext-central-exchange
build-depends:
bytestring ^>= 0.10.12.0
, gargantext
, gargantext-prelude
, nanomsg-haskell >= 0.2.4 && < 0.3
-- , nng-haskell
, optparse-applicative >= 0.18.1.0 && < 0.19
, optparse-generic ^>= 1.4.7
, postgresql-simple ^>= 0.6.4
, text ^>= 1.2.4.1
, unordered-containers ^>= 0.2.16.0
, vector ^>= 0.7.3
test-suite garg-test-tasty
import:
defaults
......
......@@ -33,6 +33,10 @@ rec {
];
});
# nng180 = pkgs.nng.overrideAttrs (new: old: rec {
# version = "1.8.0";
# });
igraph_0_10_4 = pkgs.igraph.overrideAttrs (finalAttrs: previousAttrs: {
version = "0.10.4";
......@@ -125,6 +129,8 @@ rec {
igraph_0_10_4
libpqxx
libsodium
nanomsg
# nng180
zeromq
curl
] ++ ( lib.optionals stdenv.isDarwin [
......
......@@ -8,6 +8,8 @@ Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -Wno-deprecations #-} -- FIXME(cgenie) undefined remains in code
module Gargantext.Core.AsyncUpdates
where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment