forked from BTrDB/btrdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.go
732 lines (697 loc) · 18.7 KB
/
driver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
package btrdb
//go:generate protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. grpcinterface/btrdb.proto
//go:generate protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:. grpcinterface/btrdb.proto
//don't do this automagically protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --swagger_out=logtostderr=true:. grpcinterface/btrdb.proto
import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"strings"
"time"
"github.com/pborman/uuid"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
pb "gopkg.in/BTrDB/btrdb.v4/grpcinterface"
)
//AnnotationVersion is the version of a stream annotation. It begins at 1
//for a newly created stream and increases by 1 for each SetStreamAnnotation
//call. An AnnotationVersion of 0 means "any version"
type AnnotationVersion uint64
//Endpoint is a low level connection to a single server. Rather use
//BTrDB which manages creating and destroying Endpoint objects as required
type Endpoint struct {
g pb.BTrDBClient
conn *grpc.ClientConn
}
//RawPoint represents a single timestamped value
type RawPoint struct {
//Nanoseconds since the epoch
Time int64
//Value. Units are stream-dependent
Value float64
}
var forceEp = errors.New("Not really an error, you should not see this")
type apikeyCred string
func (a apikeyCred) GetRequestMetadata(ctx context.Context, uris ...string) (map[string]string, error) {
return map[string]string{
"authorization": fmt.Sprintf("bearer %s", a),
}, nil
}
func (a apikeyCred) RequireTransportSecurity() bool {
return false
}
//ConnectEndpoint is a low level call that connects to a single BTrDB
//server. It takes multiple arguments, but it is assumed that they are
//all different addresses for the same server, in decreasing order of
//priority. It returns a Endpoint, which is generally never used directly.
//Rather use Connect()
func ConnectEndpoint(ctx context.Context, addresses ...string) (*Endpoint, error) {
return ConnectEndpointAuth(ctx, "", addresses...)
}
//ConnectEndpointAuth is a low level call that connects to a single BTrDB
//server. It takes multiple arguments, but it is assumed that they are
//all different addresses for the same server, in decreasing order of
//priority. It returns a Endpoint, which is generally never used directly.
//Rather use ConnectAuthenticated()
func ConnectEndpointAuth(ctx context.Context, apikey string, addresses ...string) (*Endpoint, error) {
if len(addresses) == 0 {
return nil, fmt.Errorf("No addresses provided")
}
ep_errors := ""
for _, a := range addresses {
if ctx.Err() != nil {
return nil, ctx.Err()
}
dl, ok := ctx.Deadline()
var tmt time.Duration
if ok {
tmt = dl.Sub(time.Now())
if tmt > 2*time.Second {
tmt = 2 * time.Second
}
} else {
tmt = 2 * time.Second
}
addrport := strings.SplitN(a, ":", 2)
if len(addrport) != 2 {
fmt.Printf("invalid address:port %q\n", a)
continue
}
secure := false
if addrport[1] == "4411" {
secure = true
}
dc := grpc.NewGZIPDecompressor()
dialopts := []grpc.DialOption{
grpc.WithTimeout(tmt),
grpc.FailOnNonTempDialError(true),
grpc.WithBlock(),
grpc.WithDecompressor(dc),
grpc.WithInitialWindowSize(1 * 1024 * 1024),
grpc.WithInitialConnWindowSize(1 * 1024 * 1024)}
if secure {
dialopts = append(dialopts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})))
} else {
dialopts = append(dialopts, grpc.WithInsecure())
}
if apikey != "" {
if !secure {
fmt.Printf("WARNING: you are using API key authentication, but are using the insecure (unencrypted) API port. This is very dangerous and should never be done. Try connecting to port 4411 instead.")
}
dialopts = append(dialopts, grpc.WithPerRPCCredentials(apikeyCred(apikey)))
}
conn, err := grpc.Dial(a, dialopts...)
if err != nil {
if ctx.Err() != nil {
return nil, ctx.Err()
}
ep_errors += fmt.Sprintf("endpoint error: err=%v a=%v\n", err, a)
continue
}
client := pb.NewBTrDBClient(conn)
rv := &Endpoint{g: client, conn: conn}
return rv, nil
}
fmt.Printf(ep_errors)
return nil, fmt.Errorf("Endpoint is unreachable on all addresses")
}
//GetGRPC will return the underlying GRPC client object.
func (b *Endpoint) GetGRPC() pb.BTrDBClient {
return b.g
}
//Disconnect will close the underlying GRPC connection. The endpoint cannot be used
//after calling this method.
func (b *Endpoint) Disconnect() error {
return b.conn.Close()
}
//Insert is a low level function, rather use Stream.Insert()
func (b *Endpoint) Insert(ctx context.Context, uu uuid.UUID, values []*pb.RawPoint) error {
rv, err := b.g.Insert(ctx, &pb.InsertParams{
Uuid: uu,
Sync: false,
Values: values,
})
if err != nil {
return err
}
if rv.GetStat() != nil {
return &CodedError{rv.GetStat()}
}
return nil
}
//FaultInject is a debugging function that allows specific low level control of the endpoint.
//If you have to read the documentation, this is not for you. Server must be started with
//$BTRDB_ENABLE_FAULT_INJECT=YES
func (b *Endpoint) FaultInject(ctx context.Context, typ uint64, args []byte) ([]byte, error) {
rv, err := b.g.FaultInject(ctx, &pb.FaultInjectParams{
Type: typ,
Params: args,
})
if err != nil {
return nil, err
}
if rv.GetStat() != nil {
return nil, &CodedError{rv.GetStat()}
}
return rv.Rv, nil
}
//Create is a low level function, rather use BTrDB.Create()
func (b *Endpoint) Create(ctx context.Context, uu uuid.UUID, collection string, tags map[string]string, annotations map[string]string) error {
taglist := []*pb.KeyValue{}
for k, v := range tags {
taglist = append(taglist, &pb.KeyValue{Key: k, Value: []byte(v)})
}
annlist := []*pb.KeyValue{}
for k, v := range annotations {
annlist = append(annlist, &pb.KeyValue{Key: k, Value: []byte(v)})
}
rv, err := b.g.Create(ctx, &pb.CreateParams{
Uuid: uu,
Collection: collection,
Tags: taglist,
Annotations: annlist,
})
if err != nil {
return err
}
if rv.GetStat() != nil {
return &CodedError{rv.GetStat()}
}
return nil
}
//ListAllCollections is a low level function, and in particular will only work
//with small numbers of collections. Rather use BTrDB.ListAllCollections()
func (b *Endpoint) ListAllCollections(ctx context.Context) ([]string, error) {
rv, err := b.g.ListCollections(ctx, &pb.ListCollectionsParams{
Prefix: "",
StartWith: "",
Limit: 1000000,
})
if err != nil {
return nil, err
}
if rv.GetStat() != nil {
return nil, &CodedError{rv.GetStat()}
}
if len(rv.Collections) >= 1000000 {
return nil, fmt.Errorf("You cannot use ListAllCollections if the number of collections exceeds 1 million. Please use ListCollections")
}
return rv.Collections, nil
}
//StreamAnnotation is a low level function, rather use Stream.Annotation()
func (b *Endpoint) StreamInfo(ctx context.Context, uu uuid.UUID, omitDescriptor bool, omitVersion bool) (
collection string,
aver AnnotationVersion,
tags map[string]string,
anns map[string]string,
version uint64, err error) {
rv, err := b.g.StreamInfo(ctx, &pb.StreamInfoParams{
Uuid: uu,
OmitDescriptor: omitDescriptor,
OmitVersion: omitVersion})
if err != nil {
return "", 0, nil, nil, 0, err
}
if rv.GetStat() != nil {
return "", 0, nil, nil, 0, &CodedError{rv.GetStat()}
}
if !omitDescriptor {
tags = make(map[string]string)
for _, kv := range rv.Descriptor_.Tags {
tags[kv.Key] = string(kv.Value)
}
anns = make(map[string]string)
for _, kv := range rv.Descriptor_.Annotations {
anns[kv.Key] = string(kv.Value)
}
aver = AnnotationVersion(rv.Descriptor_.AnnotationVersion)
collection = rv.Descriptor_.Collection
}
return collection, aver, tags, anns, rv.VersionMajor, nil
}
//SetStreamAnnotation is a low level function, rather use Stream.SetAnnotation() or Stream.CompareAndSetAnnotation()
func (b *Endpoint) SetStreamAnnotations(ctx context.Context, uu uuid.UUID, expected AnnotationVersion, changes map[string]*string) error {
ch := []*pb.KeyOptValue{}
for k, v := range changes {
kop := &pb.KeyOptValue{
Key: k,
}
if v != nil {
kop.Val = &pb.OptValue{Value: []byte(*v)}
}
ch = append(ch, kop)
}
rv, err := b.g.SetStreamAnnotations(ctx, &pb.SetStreamAnnotationsParams{Uuid: uu, ExpectedAnnotationVersion: uint64(expected), Annotations: ch})
if err != nil {
return err
}
if rv.GetStat() != nil {
return &CodedError{rv.GetStat()}
}
return nil
}
//GetMetadataUsage is a low level function. Rather use BTrDB.GetMetadataUsage
func (b *Endpoint) GetMetadataUsage(ctx context.Context, prefix string) (tags map[string]int, annotations map[string]int, err error) {
rv, err := b.g.GetMetadataUsage(ctx, &pb.MetadataUsageParams{
Prefix: prefix,
})
if err != nil {
return nil, nil, err
}
if rv.Stat != nil {
return nil, nil, &CodedError{rv.GetStat()}
}
tags = make(map[string]int)
annotations = make(map[string]int)
for _, kv := range rv.Tags {
tags[kv.Key] = int(kv.Count)
}
for _, kv := range rv.Annotations {
annotations[kv.Key] = int(kv.Count)
}
return tags, annotations, nil
}
//ListCollections is a low level function, and in particular has complex constraints. Rather use BTrDB.ListCollections()
func (b *Endpoint) ListCollections(ctx context.Context, prefix string, from string, limit uint64) ([]string, error) {
if limit > 10000 {
return nil, fmt.Errorf("Maxnumber must be <10k")
}
if limit == 0 {
limit = 10000
}
rv, err := b.g.ListCollections(ctx, &pb.ListCollectionsParams{
Prefix: prefix,
StartWith: from,
Limit: limit,
})
if err != nil {
return nil, err
}
if rv.GetStat() != nil {
return nil, &CodedError{rv.GetStat()}
}
return rv.Collections, nil
}
func streamFromLookupResult(lr *pb.StreamDescriptor, b *BTrDB) *Stream {
rv := &Stream{
uuid: lr.Uuid,
hasTags: true,
tags: make(map[string]string),
hasAnnotation: true,
annotations: make(map[string]string),
annotationVersion: AnnotationVersion(lr.AnnotationVersion),
hasCollection: true,
collection: lr.Collection,
b: b,
}
for _, kv := range lr.Tags {
rv.tags[kv.Key] = string(kv.Value)
}
for _, kv := range lr.Annotations {
rv.annotations[kv.Key] = string(kv.Value)
}
return rv
}
//LookupStreams is a low level function, rather use BTrDB.LookupStreams()
func (b *Endpoint) LookupStreams(ctx context.Context, collection string, isCollectionPrefix bool, tags map[string]*string, annotations map[string]*string, patchDB *BTrDB) (chan *Stream, chan error) {
ltags := []*pb.KeyOptValue{}
for k, v := range tags {
kop := &pb.KeyOptValue{
Key: k,
}
if v != nil {
kop.Val = &pb.OptValue{Value: []byte(*v)}
}
ltags = append(ltags, kop)
}
lanns := []*pb.KeyOptValue{}
for k, v := range annotations {
kop := &pb.KeyOptValue{
Key: k,
}
if v != nil {
kop.Val = &pb.OptValue{Value: []byte(*v)}
}
lanns = append(lanns, kop)
}
params := &pb.LookupStreamsParams{
Collection: collection,
IsCollectionPrefix: isCollectionPrefix,
Tags: ltags,
Annotations: lanns,
}
// fmt.Printf("LUS PARAMS:\ncollection: %q, pfx %v\n", collection, isCollectionPrefix)
// for _, tt := range ltags {
// fmt.Printf("tag %q -> %p\n", tt.Key, tt.Val)
// if tt.Val != nil {
// fmt.Printf(" thats %q\n", string(tt.Val.Value))
// }
// }
// for _, tt := range lanns {
// fmt.Printf("tag %q -> %p\n", tt.Key, tt.Val)
// if tt.Val != nil {
// fmt.Printf(" thats %q\n", string(tt.Val.Value))
// }
// }
rv, err := b.g.LookupStreams(ctx, params)
rvc := make(chan *Stream, 100)
rve := make(chan error, 1)
if err != nil {
close(rvc)
rve <- err
close(rve)
return rvc, rve
}
go func() {
for {
lr, err := rv.Recv()
if err == io.EOF {
close(rvc)
close(rve)
return
}
if err != nil {
close(rvc)
rve <- err
close(rve)
return
}
if lr.Stat != nil {
close(rvc)
rve <- &CodedError{lr.Stat}
close(rve)
return
}
for _, r := range lr.Results {
rvc <- streamFromLookupResult(r, patchDB)
}
}
}()
return rvc, rve
}
//RawValues is a low level function, rather use Stream.RawValues()
func (b *Endpoint) RawValues(ctx context.Context, uu uuid.UUID, start int64, end int64, version uint64) (chan RawPoint, chan uint64, chan error) {
rv, err := b.g.RawValues(ctx, &pb.RawValuesParams{
Uuid: uu,
Start: start,
End: end,
VersionMajor: version,
})
rvc := make(chan RawPoint, 100)
rvv := make(chan uint64, 1)
rve := make(chan error, 1)
wroteVer := false
if err != nil {
close(rvv)
close(rvc)
rve <- err
close(rve)
return rvc, rvv, rve
}
go func() {
for {
rawv, err := rv.Recv()
if err == io.EOF {
close(rvc)
close(rvv)
close(rve)
return
}
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return
}
if rawv.Stat != nil {
close(rvc)
close(rvv)
rve <- &CodedError{rawv.Stat}
close(rve)
return
}
if !wroteVer {
rvv <- rawv.VersionMajor
wroteVer = true
}
for _, x := range rawv.Values {
rvc <- RawPoint{x.Time, x.Value}
}
}
}()
return rvc, rvv, rve
}
//AlignedWindows is a low level function, rather use Stream.AlignedWindows()
func (b *Endpoint) AlignedWindows(ctx context.Context, uu uuid.UUID, start int64, end int64, pointwidth uint8, version uint64) (chan StatPoint, chan uint64, chan error) {
rv, err := b.g.AlignedWindows(ctx, &pb.AlignedWindowsParams{
Uuid: uu,
Start: start,
End: end,
PointWidth: uint32(pointwidth),
VersionMajor: version,
})
rvc := make(chan StatPoint, 100)
rvv := make(chan uint64, 1)
rve := make(chan error, 1)
wroteVer := false
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return rvc, rvv, rve
}
go func() {
for {
rawv, err := rv.Recv()
if err == io.EOF {
close(rvc)
close(rvv)
close(rve)
return
}
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return
}
if rawv.Stat != nil {
close(rvc)
close(rvv)
rve <- &CodedError{rawv.Stat}
close(rve)
return
}
if !wroteVer {
rvv <- rawv.VersionMajor
wroteVer = true
}
for _, x := range rawv.Values {
rvc <- StatPoint{
Time: x.Time,
Min: x.Min,
Mean: x.Mean,
Max: x.Max,
Count: x.Count,
}
}
}
}()
return rvc, rvv, rve
}
//Windows is a low level function, rather use Stream.Windows()
func (b *Endpoint) Windows(ctx context.Context, uu uuid.UUID, start int64, end int64, width uint64, depth uint8, version uint64) (chan StatPoint, chan uint64, chan error) {
rv, err := b.g.Windows(ctx, &pb.WindowsParams{
Uuid: uu,
Start: start,
End: end,
Width: width,
Depth: uint32(depth),
VersionMajor: version,
})
rvc := make(chan StatPoint, 100)
rvv := make(chan uint64, 1)
rve := make(chan error, 1)
wroteVer := false
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return rvc, rvv, rve
}
go func() {
for {
rawv, err := rv.Recv()
if err == io.EOF {
close(rvc)
close(rvv)
close(rve)
return
}
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return
}
if rawv.Stat != nil {
close(rvc)
close(rvv)
rve <- &CodedError{rawv.Stat}
close(rve)
return
}
if !wroteVer {
rvv <- rawv.VersionMajor
wroteVer = true
}
for _, x := range rawv.Values {
rvc <- StatPoint{
Time: x.Time,
Min: x.Min,
Mean: x.Mean,
Max: x.Max,
Count: x.Count,
}
}
}
}()
return rvc, rvv, rve
}
//DeleteRange is a low level function, rather use Stream.DeleteRange()
func (b *Endpoint) DeleteRange(ctx context.Context, uu uuid.UUID, start int64, end int64) (uint64, error) {
rv, err := b.g.Delete(ctx, &pb.DeleteParams{
Uuid: uu,
Start: start,
End: end,
})
if err != nil {
return 0, err
}
if rv.Stat != nil {
return 0, &CodedError{rv.Stat}
}
return rv.VersionMajor, nil
}
//Flush is a low level function, rather use Stream.Flush()
func (b *Endpoint) Flush(ctx context.Context, uu uuid.UUID) error {
rv, err := b.g.Flush(ctx, &pb.FlushParams{
Uuid: uu,
})
if err != nil {
return err
}
if rv.Stat != nil {
return &CodedError{rv.Stat}
}
return nil
}
//Obliterate is a low level function, rather use Stream.Obliterate()
func (b *Endpoint) Obliterate(ctx context.Context, uu uuid.UUID) error {
rv, err := b.g.Obliterate(ctx, &pb.ObliterateParams{
Uuid: uu,
})
if err != nil {
return err
}
if rv.Stat != nil {
return &CodedError{rv.Stat}
}
return nil
}
//Info is a low level function, rather use BTrDB.Info()
func (b *Endpoint) Info(ctx context.Context) (*MASH, *pb.InfoResponse, error) {
rv, err := b.g.Info(ctx, &pb.InfoParams{})
if err != nil {
return nil, nil, err
}
if rv.Stat != nil {
return nil, nil, &CodedError{rv.Stat}
}
mrv := &MASH{rv.Mash, nil}
if rv.Mash != nil {
mrv.precalculate()
}
return mrv, rv, nil
}
//Nearest is a low level function, rather use Stream.Nearest()
func (b *Endpoint) Nearest(ctx context.Context, uu uuid.UUID, time int64, version uint64, backward bool) (RawPoint, uint64, error) {
rv, err := b.g.Nearest(ctx, &pb.NearestParams{
Uuid: uu,
Time: time,
VersionMajor: version,
Backward: backward,
})
if err != nil {
return RawPoint{}, 0, err
}
if rv.Stat != nil {
return RawPoint{}, 0, &CodedError{rv.Stat}
}
return RawPoint{Time: rv.Value.Time, Value: rv.Value.Value}, rv.VersionMajor, nil
}
type ChangedRange struct {
Version uint64
Start int64
End int64
}
//Changes is a low level function, rather use BTrDB.Changes()
func (b *Endpoint) Changes(ctx context.Context, uu uuid.UUID, fromVersion uint64, toVersion uint64, resolution uint8) (chan ChangedRange, chan uint64, chan error) {
rv, err := b.g.Changes(ctx, &pb.ChangesParams{
Uuid: uu,
FromMajor: fromVersion,
ToMajor: toVersion,
Resolution: uint32(resolution),
})
rvc := make(chan ChangedRange, 100)
rvv := make(chan uint64, 1)
rve := make(chan error, 1)
wroteVer := false
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return rvc, rvv, rve
}
go func() {
for {
cr, err := rv.Recv()
if err == io.EOF {
close(rvc)
close(rvv)
close(rve)
return
}
if err != nil {
close(rvc)
close(rvv)
rve <- err
close(rve)
return
}
if cr.Stat != nil {
close(rvc)
close(rvv)
rve <- &CodedError{cr.Stat}
close(rve)
return
}
if !wroteVer {
rvv <- cr.VersionMajor
wroteVer = true
}
for _, x := range cr.Ranges {
rvc <- ChangedRange{Version: cr.VersionMajor, Start: x.Start, End: x.End}
}
}
}()
return rvc, rvv, rve
}