Skip to content

Commit 647609d

Browse files
committed
queue: make example executable
- Make example executable - Add description how-to run example manually
1 parent fee7154 commit 647609d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

queue/example_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Setup queue module and start Tarantool instance before execution:
2+
// Terminal 1:
3+
// $ make deps
4+
// $ TT_LISTEN=3013 tarantool queue/config.lua
5+
//
6+
// Terminal 2:
7+
// $ cd queue
8+
// $ go test -v example_test.go
19
package queue_test
210

311
import (
@@ -8,16 +16,22 @@ import (
816
"github.com/tarantool/go-tarantool/queue"
917
)
1018

11-
func ExampleConnection_Queue() {
19+
// Example_simpleQueue demonstrates an operations like Put and Take with queue.
20+
func Example_simpleQueue() {
1221
cfg := queue.Cfg{
1322
Temporary: false,
1423
Kind: queue.FIFO,
1524
Opts: queue.Opts{
1625
Ttl: 10 * time.Second,
1726
},
1827
}
28+
opts := tarantool.Opts{
29+
Timeout: 2500 * time.Millisecond,
30+
User: "test",
31+
Pass: "test",
32+
}
1933

20-
conn, err := tarantool.Connect(server, opts)
34+
conn, err := tarantool.Connect("127.0.0.1:3013", opts)
2135
if err != nil {
2236
fmt.Printf("error in prepare is %v", err)
2337
return
@@ -64,4 +78,6 @@ func ExampleConnection_Queue() {
6478
fmt.Printf("Task should be nil, but %d", task.Id())
6579
return
6680
}
81+
82+
// Output: data_1: test_data_1
6783
}

0 commit comments

Comments
 (0)