作者 kevin

refactor the code

@@ -55,21 +55,23 @@ func (w *Writer) execute(vals []interface{}) { @@ -55,21 +55,23 @@ func (w *Writer) execute(vals []interface{}) {
55 bulk.Add(req) 55 bulk.Add(req)
56 } 56 }
57 resp, err := bulk.Do(context.Background()) 57 resp, err := bulk.Do(context.Background())
58 -  
59 if err != nil { 58 if err != nil {
60 logx.Error(err) 59 logx.Error(err)
61 return 60 return
62 } 61 }
63 62
64 // bulk error in docs will report in response items 63 // bulk error in docs will report in response items
65 - if resp.Errors { 64 + if !resp.Errors {
  65 + return
  66 + }
  67 +
66 for _, imap := range resp.Items { 68 for _, imap := range resp.Items {
67 for _, item := range imap { 69 for _, item := range imap {
68 if item.Error == nil { 70 if item.Error == nil {
69 continue 71 continue
70 } 72 }
  73 +
71 logx.Error(item.Error) 74 logx.Error(item.Error)
72 } 75 }
73 } 76 }
74 - }  
75 } 77 }