12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import RediStack
16
- import RESP3
15
+ @_spi ( RESP3) import RediStack
17
16
import Foundation
18
17
import NIOCore
19
18
import NIOEmbedded
20
19
21
- func benchmarkRESPProtocol ( ) throws {
20
+ func runRESPProtocol ( ) throws {
22
21
let channel = EmbeddedChannel ( )
23
22
try channel. pipeline. addBaseRedisHandlers ( ) . wait ( )
24
23
@@ -28,29 +27,26 @@ func benchmarkRESPProtocol() throws {
28
27
let serverValue = " Hello, world "
29
28
let replyValue = RESPValue . simpleString ( ByteBuffer ( string: serverValue) )
30
29
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 " )
54
50
}
55
51
56
52
guard case . clean = try channel. finish ( ) else {
0 commit comments