Skip to content

Commit 49cff95

Browse files
copy -> clone + separate method in pool example
1 parent cf20d6a commit 49cff95

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

connection_pool/example_test.go

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,21 @@ func ExampleConnectionPool_NewPrepared() {
575575
}
576576
}
577577

578+
func getTestTxnOpts() tarantool.Opts {
579+
txnOpts := connOpts.Clone()
580+
581+
// Assert that server supports expected protocol features
582+
txnOpts.RequiredProtocolInfo = tarantool.ProtocolInfo{
583+
Version: tarantool.ProtocolVersion(1),
584+
Features: []tarantool.ProtocolFeature{
585+
tarantool.StreamsFeature,
586+
tarantool.TransactionsFeature,
587+
},
588+
}
589+
590+
return txnOpts
591+
}
592+
578593
func ExampleCommitRequest() {
579594
var req tarantool.Request
580595
var resp *tarantool.Response
@@ -586,16 +601,7 @@ func ExampleCommitRequest() {
586601
return
587602
}
588603

589-
// Assert that server supports expected features
590-
txnOpts := connOpts.Copy()
591-
txnOpts.RequiredProtocolInfo = tarantool.ProtocolInfo{
592-
Version: tarantool.ProtocolVersion(1),
593-
Features: []tarantool.ProtocolFeature{
594-
tarantool.StreamsFeature,
595-
tarantool.TransactionsFeature,
596-
},
597-
}
598-
604+
txnOpts := getTestTxnOpts()
599605
pool, err := examplePool(testRoles, txnOpts)
600606
if err != nil {
601607
fmt.Println(err)
@@ -682,16 +688,7 @@ func ExampleRollbackRequest() {
682688
return
683689
}
684690

685-
// Assert that server supports expected features
686-
txnOpts := connOpts.Copy()
687-
txnOpts.RequiredProtocolInfo = tarantool.ProtocolInfo{
688-
Version: tarantool.ProtocolVersion(1),
689-
Features: []tarantool.ProtocolFeature{
690-
tarantool.StreamsFeature,
691-
tarantool.TransactionsFeature,
692-
},
693-
}
694-
691+
txnOpts := getTestTxnOpts()
695692
// example pool has only one rw instance
696693
pool, err := examplePool(testRoles, txnOpts)
697694
if err != nil {
@@ -778,16 +775,7 @@ func ExampleBeginRequest_TxnIsolation() {
778775
return
779776
}
780777

781-
// Assert that server supports expected features
782-
txnOpts := connOpts.Copy()
783-
txnOpts.RequiredProtocolInfo = tarantool.ProtocolInfo{
784-
Version: tarantool.ProtocolVersion(1),
785-
Features: []tarantool.ProtocolFeature{
786-
tarantool.StreamsFeature,
787-
tarantool.TransactionsFeature,
788-
},
789-
}
790-
778+
txnOpts := getTestTxnOpts()
791779
// example pool has only one rw instance
792780
pool, err := examplePool(testRoles, txnOpts)
793781
if err != nil {

0 commit comments

Comments
 (0)