Skip to content

Commit

Permalink
Merge pull request #33 from ford-prefect/queue-fixes
Browse files Browse the repository at this point in the history
Update based on queue API fixes in purescript-redis
  • Loading branch information
iamnewspecies authored Mar 11, 2019
2 parents a0a9e24 + 4581008 commit bc1c57e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions src/Presto/Backend/Language/Flow.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -287,15 +287,15 @@ 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

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
Expand Down
14 changes: 7 additions & 7 deletions src/Presto/Backend/Language/Interpreter.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit bc1c57e

Please sign in to comment.