1212//
1313//===----------------------------------------------------------------------===//
1414
15- import RediStack
16- import RESP3
15+ @_spi ( RESP3) import RediStack
1716import Foundation
1817import NIOCore
1918import NIOEmbedded
2019
21- func benchmarkRESPProtocol ( ) throws {
20+ func runRESPProtocol ( ) throws {
2221 let channel = EmbeddedChannel ( )
2322 try channel. pipeline. addBaseRedisHandlers ( ) . wait ( )
2423
@@ -28,29 +27,26 @@ func benchmarkRESPProtocol() throws {
2827 let serverValue = " Hello, world "
2928 let replyValue = RESPValue . simpleString ( ByteBuffer ( string: serverValue) )
3029 RESPTranslator ( ) . write ( replyValue, into: & redisReplyBuffer)
31-
32- try benchmark {
33- let promise = channel. eventLoop. makePromise ( of: RESPValue . self)
34-
35- // Client sends a command
36- try channel. writeOutbound ( RedisCommand (
37- message: . array( [
38- . bulkString( ByteBuffer ( string: " GET " ) ) ,
39- . bulkString( ByteBuffer ( string: " welcome " ) ) ,
40- ] ) ,
41- responsePromise: promise
42- ) )
43-
44- // Server reads the command
45- _ = try channel. readOutbound ( as: ByteBuffer . self)
46- // Server replies
47- try channel. writeInbound ( redisReplyBuffer)
48-
49- // Client reads the reply
50- let serverReply = try promise. futureResult. wait ( )
51- guard serverReply. string == serverValue else {
52- fatalError ( " Invalid test result " )
53- }
30+ let promise = channel. eventLoop. makePromise ( of: RESPValue . self)
31+
32+ // Client sends a command
33+ try channel. writeOutbound ( RedisCommand (
34+ message: . array( [
35+ . bulkString( ByteBuffer ( string: " GET " ) ) ,
36+ . bulkString( ByteBuffer ( string: " welcome " ) ) ,
37+ ] ) ,
38+ responsePromise: promise
39+ ) )
40+
41+ // Server reads the command
42+ _ = try channel. readOutbound ( as: ByteBuffer . self)
43+ // Server replies
44+ try channel. writeInbound ( redisReplyBuffer)
45+
46+ // Client reads the reply
47+ let serverReply = try promise. futureResult. wait ( )
48+ guard serverReply. string == serverValue else {
49+ fatalError ( " Invalid test result " )
5450 }
5551
5652 guard case . clean = try channel. finish ( ) else {
0 commit comments