Skip to content

Commit

Permalink
Expose Result struct so that it can be used outside the library
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed May 30, 2015
1 parent fe4aa75 commit 3c08593
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions recordset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
. "github.com/aerospike/aerospike-client-go/types/atomic"
)

type result struct {
type Result struct {
Record *Record
Err error
}
Expand Down Expand Up @@ -80,29 +80,29 @@ func (rcs *Recordset) IsActive() bool {
// fmt.Println(res.Record.Bins)
// }
// }
func (rcs *Recordset) Results() <-chan *result {
res := make(chan *result, len(rcs.Records))
func (rcs *Recordset) Results() <-chan *Result {
res := make(chan *Result, len(rcs.Records))

go func() {
L:
for {
select {
case r := <-rcs.Records:
if r != nil {
res <- &result{Record: r, Err: nil}
res <- &Result{Record: r, Err: nil}
} else {
close(res)
break L
}
case e := <-rcs.Errors:
if e != nil {
res <- &result{Record: nil, Err: e}
res <- &Result{Record: nil, Err: e}
}
}
}
}()

return (<-chan *result)(res)
return (<-chan *Result)(res)
}

// Close all streams from different nodes.
Expand Down

0 comments on commit 3c08593

Please sign in to comment.