@@ -13,9 +13,7 @@ final class ReliableQueue {
1313
1414 private let redisAdaptor : Adaptor
1515
16- private let blockingRedisAdaptor : Adaptor // Maybe have a pool here instead
17-
18- private let ipAddress = IPAddress ( ) . address
16+ private let hostName = Host ( ) . name
1917
2018 private let consumer : String ?
2119
@@ -26,7 +24,6 @@ final class ReliableQueue {
2624 self . queue = queue
2725 self . consumer = consumer
2826 self . redisAdaptor = try RedisAdaptor ( config: config)
29- self . blockingRedisAdaptor = try RedisAdaptor ( config: config)
3027 }
3128
3229
@@ -35,7 +32,7 @@ final class ReliableQueue {
3532 }
3633
3734 var consumerName : String {
38- return consumer ?? ipAddress
35+ return consumer ?? hostName
3936 }
4037
4138
@@ -112,11 +109,11 @@ final class ReliableQueue {
112109 . string( RedisKey . workQ ( queue) . name) ,
113110 . string( processingQKey) ,
114111 . string( " 0 " ) ] )
115- return try blockingRedisAdaptor . execute ( dequeueCommand) . string
112+ return try redisAdaptor . execute ( dequeueCommand) . string
116113 . map { id in
117114 return Command ( command: " GET " , args: [ . string( id) ] )
118115 } . flatMap { command in
119- return try blockingRedisAdaptor . execute ( command) . data
116+ return try redisAdaptor . execute ( command) . data
120117 }
121118 }
122119
@@ -126,9 +123,11 @@ final class ReliableQueue {
126123 let incrKey = success ? RedisKey . success ( consumerName) . name : RedisKey . failure ( consumerName) . name
127124 try redisAdaptor. pipeline {
128125 let commands = [
126+ Command ( command: " MULTI " ) ,
129127 Command ( command: " LREM " , args: [ . string( processingQKey) , . string( " 0 " ) , . string( item. uuid) ] ) ,
130128 Command ( command: " INCR " , args: [ . string( incrKey) ] ) ,
131- Command ( command: " DEL " , args: [ . string( item. uuid) ] )
129+ Command ( command: " DEL " , args: [ . string( item. uuid) ] ) ,
130+ Command ( command: " EXEC " )
132131 ]
133132 return commands
134133 }
0 commit comments