From 45810082a8d27cdc92ccc40d566170d117e90279 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Wed, 6 Mar 2019 15:57:02 +0530 Subject: [PATCH] Update based on queue API fixes in purescript-redis purescript-redis has renamed enqueue/dequeue to underlying Redis commands (rpop/lpush), and fixed the corresponding return types. --- bower.json | 2 +- src/Presto/Backend/Language/Flow.purs | 10 +++++----- src/Presto/Backend/Language/Interpreter.purs | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bower.json b/bower.json index 6400c35..f08e0d0 100644 --- a/bower.json +++ b/bower.json @@ -25,7 +25,7 @@ "purescript-sequelize": "https://github.com/juspay/purescript-sequelize.git#0.1.2", "purescript-body-parser": "https://github.com/juspay/purescript-body-parser.git#0.1.0", "purescript-uuid": "^4.0.0", - "purescript-redis": "https://github.com/juspay/purescript-redis.git#0.1.1", + "purescript-redis": "https://github.com/juspay/purescript-redis.git#0.1.2", "purescript-now": "3.0.0" }, "devDependencies": { diff --git a/src/Presto/Backend/Language/Flow.purs b/src/Presto/Backend/Language/Flow.purs index cab8388..83da3c8 100644 --- a/src/Presto/Backend/Language/Flow.purs +++ b/src/Presto/Backend/Language/Flow.purs @@ -36,7 +36,7 @@ import Presto.Backend.DB (findOne, findAll, create, createWithOpts, query, updat import Presto.Backend.Types (BackendAff) import Presto.Core.Types.API (class RestEndpoint, Headers) import Presto.Core.Types.Language.APIInteract (apiInteract) -import Presto.Core.Types.Language.Flow (APIResult, Control) +import Presto.Core.Types.Language.Flow (APIResult) import Presto.Core.Types.Language.Interaction (Interaction) import Sequelize.Class (class Model) import Sequelize.Types (Conn) @@ -64,8 +64,8 @@ data BackendFlowCommands next st rt s = | SetCacheWithExpiry CacheConn String String String (Either Error String -> next) | GetCache CacheConn String (Either Error String -> next) | DelCache CacheConn String (Either Error String -> next) - | Enqueue CacheConn String String (Either Error String -> next) - | Dequeue CacheConn String (Either Error String -> next) + | Enqueue CacheConn String String (Either Error Unit -> next) + | Dequeue CacheConn String (Either Error (Maybe String) -> next) | GetQueueIdx CacheConn String Int (Either Error String -> next) | Fork (BackendFlow st rt s) (Unit -> next) | Expire CacheConn String String (Either Error String -> next) @@ -287,7 +287,7 @@ subscribe cacheName channel = do enqueueInMulti :: forall st rt. Multi -> String -> String -> BackendFlow st rt Multi enqueueInMulti multi listName value = wrap $ EnqueueInMulti multi listName value id -enqueue :: forall st rt. String -> String -> String -> BackendFlow st rt (Either Error String) +enqueue :: forall st rt. String -> String -> String -> BackendFlow st rt (Either Error Unit) enqueue cacheName listName value = do cacheConn <- getCacheConn cacheName wrap $ Enqueue cacheConn listName value id @@ -295,7 +295,7 @@ enqueue cacheName listName value = do dequeueInMulti :: forall st rt. Multi -> String -> BackendFlow st rt Multi dequeueInMulti multi listName = wrap $ DequeueInMulti multi listName id -dequeue :: forall st rt. String -> String -> BackendFlow st rt (Either Error String) +dequeue :: forall st rt. String -> String -> BackendFlow st rt (Either Error (Maybe String)) dequeue cacheName listName = do cacheConn <- getCacheConn cacheName wrap $ Dequeue cacheConn listName id diff --git a/src/Presto/Backend/Language/Interpreter.purs b/src/Presto/Backend/Language/Interpreter.purs index 5a889fb..260e103 100644 --- a/src/Presto/Backend/Language/Interpreter.purs +++ b/src/Presto/Backend/Language/Interpreter.purs @@ -23,7 +23,7 @@ module Presto.Backend.Interpreter where import Prelude -import Cache (CacheConn, delKey, dequeue, dequeueMulti, enqueue, enqueueMulti, expire, expireMulti, getHashKey, getHashKeyMulti, getKey, getKeyMulti, getMulti, getQueueIdx, getQueueIdxMulti, incr, incrMulti, publishToChannel, publishToChannelMulti, set, setHash, setHashMulti, setKey, setKeyMulti, setMessageHandler, setMulti, setex, setexKeyMulti, subscribe, subscribeMulti) +import Cache (CacheConn, delKey, lpop, lpopMulti, rpush, rpushMulti, expire, expireMulti, getHashKey, getHashKeyMulti, getKey, getKeyMulti, getMulti, lindex, lindexMulti, incr, incrMulti, publishToChannel, publishToChannelMulti, set, setHash, setHashMulti, setKey, setKeyMulti, setMessageHandler, setMulti, setex, setexKeyMulti, subscribe, subscribeMulti) import Control.Monad.Aff (Aff, forkAff) import Control.Monad.Eff.Exception (Error, error) import Control.Monad.Except.Trans (ExceptT(..), lift, throwError, runExceptT) as E @@ -104,11 +104,11 @@ interpret _ (Subscribe cacheConn channel next) = (R.lift $ S.lift $ E.lift $ sub interpret _ (SetMessageHandler cacheConn f next) = (R.lift $ S.lift $ E.lift $ setMessageHandler cacheConn f) >>= (pure <<< next) -interpret _ (Enqueue cacheConn listName value next) = (R.lift $ S.lift $ E.lift $ enqueue cacheConn listName value) >>= (pure <<< next) +interpret _ (Enqueue cacheConn listName value next) = (R.lift $ S.lift $ E.lift $ void <$> rpush cacheConn listName value) >>= (pure <<< next) -interpret _ (Dequeue cacheConn listName next) = (R.lift $ S.lift $ E.lift $ dequeue cacheConn listName) >>= (pure <<< next) +interpret _ (Dequeue cacheConn listName next) = (R.lift $ S.lift $ E.lift $ lpop cacheConn listName) >>= (pure <<< next) -interpret _ (GetQueueIdx cacheConn listName index next) = (R.lift $ S.lift $ E.lift $ getQueueIdx cacheConn listName index) >>= (pure <<< next) +interpret _ (GetQueueIdx cacheConn listName index next) = (R.lift $ S.lift $ E.lift $ lindex cacheConn listName index) >>= (pure <<< next) interpret _ (GetMulti cacheConn next) = (R.lift $ S.lift $ E.lift $ getMulti cacheConn) >>= (pure <<< next) @@ -134,11 +134,11 @@ interpret _ (PublishToChannelInMulti multi channel message next) = (R.lift <<< S interpret _ (SubscribeInMulti multi channel next) = (R.lift <<< S.lift <<< E.lift <<< subscribeMulti channel $ multi) >>= (pure <<< next) -interpret _ (EnqueueInMulti multi listName val next) = (R.lift <<< S.lift <<< E.lift <<< enqueueMulti listName val $ multi) >>= (pure <<< next) +interpret _ (EnqueueInMulti multi listName val next) = (R.lift <<< S.lift <<< E.lift <<< rpushMulti listName val $ multi) >>= (pure <<< next) -interpret _ (DequeueInMulti multi listName next) = (R.lift <<< S.lift <<< E.lift <<< dequeueMulti listName $ multi) >>= (pure <<< next) +interpret _ (DequeueInMulti multi listName next) = (R.lift <<< S.lift <<< E.lift <<< lpopMulti listName $ multi) >>= (pure <<< next) -interpret _ (GetQueueIdxInMulti multi listName index next) = (R.lift <<< S.lift <<< E.lift <<< getQueueIdxMulti listName index $ multi) >>= (pure <<< next) +interpret _ (GetQueueIdxInMulti multi listName index next) = (R.lift <<< S.lift <<< E.lift <<< lindexMulti listName index $ multi) >>= (pure <<< next) interpret (BackendRuntime a connections c) (GetCacheConn cacheName next) = do maybeCache <- pure $ lookup cacheName connections