@@ -998,6 +998,94 @@ func ExampleBeginRequest_TxnIsolation() {
998998 fmt .Printf ("Select after Rollback: response is %#v\n " , data )
999999}
10001000
1001+ func ExampleBeginRequest_IsSync () {
1002+ conn := exampleConnect (dialer , opts )
1003+ defer conn .Close ()
1004+
1005+ // Tarantool supports IS_SYNC flag for BeginRequest since version 3.1.0
1006+ isLess , err := test_helpers .IsTarantoolVersionLess (3 , 1 , 0 )
1007+ if err != nil || isLess {
1008+ return
1009+ }
1010+
1011+ stream , err := conn .NewStream ()
1012+ if err != nil {
1013+ fmt .Printf ("error getting the stream: %s\n " , err )
1014+ return
1015+ }
1016+
1017+ // Begin transaction with synchronous mode
1018+ req := tarantool .NewBeginRequest ().IsSync (true )
1019+ resp , err := stream .Do (req ).GetResponse ()
1020+ switch {
1021+ case err != nil :
1022+ fmt .Printf ("error getting the response: %s\n " , err )
1023+ case resp .Header ().Error != tarantool .ErrorNo :
1024+ fmt .Printf ("response error code: %s\n " , resp .Header ().Error )
1025+ default :
1026+ fmt .Println ("Success." )
1027+ }
1028+ // Output:
1029+ // Success.
1030+ }
1031+
1032+ func ExampleCommitRequest_IsSync () {
1033+ conn := exampleConnect (dialer , opts )
1034+ defer conn .Close ()
1035+
1036+ // Tarantool supports IS_SYNC flag for CommitRequest since version 3.1.0q
1037+ isLess , err := test_helpers .IsTarantoolVersionLess (3 , 1 , 0 )
1038+ if err != nil || isLess {
1039+ return
1040+ }
1041+
1042+ var req tarantool.Request
1043+
1044+ stream , err := conn .NewStream ()
1045+ if err != nil {
1046+ fmt .Printf ("error getting the stream: %s\n " , err )
1047+ return
1048+ }
1049+
1050+ // Begin transaction
1051+ req = tarantool .NewBeginRequest ()
1052+ resp , err := stream .Do (req ).GetResponse ()
1053+ switch {
1054+ case err != nil :
1055+ fmt .Printf ("error getting the response: %s\n " , err )
1056+ return
1057+ case resp .Header ().Error != tarantool .ErrorNo :
1058+ fmt .Printf ("response error code: %s\n " , resp .Header ().Error )
1059+ return
1060+ }
1061+
1062+ // Insert in stream
1063+ req = tarantool .NewReplaceRequest ("test" ).Tuple ([]interface {}{1 , "test" })
1064+ resp , err = stream .Do (req ).GetResponse ()
1065+ switch {
1066+ case err != nil :
1067+ fmt .Printf ("error getting the response: %s\n " , err )
1068+ return
1069+ case resp .Header ().Error != tarantool .ErrorNo :
1070+ fmt .Printf ("response error code: %s\n " , resp .Header ().Error )
1071+ return
1072+ }
1073+
1074+ // Commit transaction in sync mode
1075+ req = tarantool .NewCommitRequest ().IsSync (true )
1076+ resp , err = stream .Do (req ).GetResponse ()
1077+ switch {
1078+ case err != nil :
1079+ fmt .Printf ("error getting the response: %s\n " , err )
1080+ case resp .Header ().Error != tarantool .ErrorNo :
1081+ fmt .Printf ("response error code: %s\n " , resp .Header ().Error )
1082+ default :
1083+ fmt .Println ("Success." )
1084+ }
1085+ // Output:
1086+ // Success.
1087+ }
1088+
10011089func ExampleErrorNo () {
10021090 conn := exampleConnect (dialer , opts )
10031091 defer conn .Close ()
0 commit comments