mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 03:00:26 +01:00
interleaver: Do not share error in producer and consumer.
This commit is contained in:
parent
fc50897d2d
commit
307d1aec44
|
@ -48,7 +48,7 @@ func selectKeyEncoder(interleaved bool) common.KeyEncoder {
|
|||
return common.EncodeStringToBytes
|
||||
}
|
||||
|
||||
func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err error) {
|
||||
func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) error {
|
||||
|
||||
blocks := make(chan *Block)
|
||||
done := make(chan struct{})
|
||||
|
@ -58,7 +58,7 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err
|
|||
defer close(blocks)
|
||||
for {
|
||||
block := new(Block)
|
||||
if err = producer.Next(block); err != nil {
|
||||
if err := producer.Next(block); err != nil {
|
||||
if err != ErrNoMoreBlocks {
|
||||
log.Printf("Reading failed: %s\n", err)
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err
|
|||
|
||||
i := 0
|
||||
for block := range blocks {
|
||||
if err = consumer.Consume(block); err != nil {
|
||||
return
|
||||
if err := consumer.Consume(block); err != nil {
|
||||
return err
|
||||
}
|
||||
i++
|
||||
if i%1000 == 0 {
|
||||
|
@ -84,7 +84,7 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err
|
|||
}
|
||||
log.Printf("%d blocks transferred in total.\n", i)
|
||||
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user