ThinkingDataAnalytics / go-sdk

ThinkingData SDK for Golang
Apache License 2.0
9 stars 13 forks source link

close之后直接return疑问 #3

Closed weiwenwang closed 2 years ago

weiwenwang commented 4 years ago
for {
            flush := false
            select {
            case rec, ok := <-c.ch:
                if !ok {
                    return
                }

channel发现close之后直接return,buffer里面还有数据没法送,是不是就丢了

xuzz1 commented 4 years ago
for {
          flush := false
          select {
          case rec, ok := <-c.ch:
              if !ok {
                  return
              }

channel发现close之后直接return,buffer里面还有数据没法送,是不是就丢了

一般是停服之后再调用close方法,最后调用close,调用close方法之前会刷新buffer里面的数据,buffer数据发送完了,channel才会关闭,数据不会丢弃的吧? func (c *BatchConsumer) Close() error { c.Flush() close(c.ch) c.wg.Wait() return nil }