-
-
Notifications
You must be signed in to change notification settings - Fork 177
Closed
Description
Running the following code:
package main
import (
"fmt"
"log"
rt "github.com/dancannon/gorethink"
)
type T struct {
Id string
A bool
B int
}
func main() {
db, err := rt.Connect(rt.ConnectOpts{
Address: rethinkServerAddr,
})
if err != nil {
log.Fatal(err)
}
defer db.Close()
db.SetMaxOpenConns(20)
db.SetMaxIdleConns(20)
go func() {
stream, err := rt.Db("test").Table("ts").Changes().Field("new_val").Run(db)
if err != nil {
log.Println(err)
return
}
v := T{}
for stream.Next(&v) {
//To avoid race condition/overwrite by next call.
func(x T) {
fmt.Printf("%#v\n", x)
}(v)
}
err = stream.Err()
if err != nil {
log.Println(err)
}
log.Println("END OF stream.")
}()
for i := 0; i < 30; i++ {
err := rt.Db("test").Table("ts").Insert(T{A: i%2 == 0, B: i}).Exec(db)
if err != nil {
log.Fatal(err)
}
}
}Will give you, some Ids missing:
main.T{Id:"ff5c1e65-9ab1-49b8-befc-b5efca5af414", A:false, B:1}
main.T{Id:"6ca2c8de-9b6e-43d5-910b-fcf849890652", A:true, B:2}
main.T{Id:"9ebb807d-2604-4017-8ad3-70c50a75cac2", A:false, B:3}
main.T{Id:"ce006af3-aba3-4997-8837-5e839b1d9f9d", A:true, B:4}
main.T{Id:"802178f4-29bb-4eea-a54a-75a14ebdee00", A:false, B:5}
main.T{Id:"2ebddde6-5d49-4730-be96-232c64292a79", A:true, B:6}
main.T{Id:"9b7b14da-4030-4cd6-baea-6926c3639faf", A:false, B:7}
main.T{Id:"a0717c2d-dd35-444b-b0f2-7fd8a9aac279", A:true, B:8}
main.T{Id:"d69d5f68-f78d-46ea-853f-59239005fbf3", A:false, B:9}
main.T{Id:"946de5c6-c107-44a6-8e21-f85e54ace4b8", A:true, B:10}
main.T{Id:"bef36a90-e96c-4584-a983-82b626d127a8", A:false, B:11}
main.T{Id:"", A:true, B:12}
main.T{Id:"ad108124-908b-4b2a-92bd-186a8f1878ad", A:false, B:13}
main.T{Id:"4f665222-6edf-4eec-a870-4d2eedd84703", A:true, B:14}
main.T{Id:"", A:false, B:15}
main.T{Id:"d0bf350d-d3f1-4fb7-bc58-2f4ceec927cd", A:true, B:16}
main.T{Id:"", A:false, B:17}
main.T{Id:"fa075833-d07c-454d-bca6-dff1524a3254", A:true, B:18}
main.T{Id:"", A:false, B:19}
main.T{Id:"b1fdda33-aea9-4dae-959c-c8719fc158d6", A:true, B:20}
main.T{Id:"8431c425-424f-4247-a668-6ea15ec88f99", A:false, B:21}
main.T{Id:"", A:true, B:22}
main.T{Id:"d088c93c-879c-4ccd-a10d-d09b4daaa9f4", A:false, B:23}
main.T{Id:"", A:true, B:24}
main.T{Id:"9696a198-7ce9-4dc0-a1f4-02d10ce38412", A:false, B:25}
main.T{Id:"627a2974-1590-4f59-8182-6a81beec84e2", A:true, B:26}
main.T{Id:"a086c9c6-c146-405d-bcf3-2af03b042b6d", A:false, B:27}
main.T{Id:"90f3e7d3-38b0-43cc-b778-9d889023cf5c", A:true, B:28}
main.T{Id:"47c21238-8eb5-419c-9cfb-b2d1df61b02d", A:false, B:29}
While running r.db('test').table('ts').changes()("new_val") in Data Explorer shows a correct id per document.