Method
Write
(evtsc <-chan *event.Event, errs <-chan error)
Source from the content-addressed store, hash-verified
| 184 | } |
| 185 | |
| 186 | func (w *writer) Write(evtsc <-chan *event.Event, errs <-chan error) chan error { |
| 187 | errsc := make(chan error, 100) |
| 188 | go func() { |
| 189 | for { |
| 190 | select { |
| 191 | case evt := <-evtsc: |
| 192 | b := evt.MarshalRaw() |
| 193 | l := len(b) |
| 194 | if l == 0 { |
| 195 | continue |
| 196 | } |
| 197 | // write event buffer |
| 198 | err := w.write(b) |
| 199 | if err != nil { |
| 200 | errsc <- err |
| 201 | continue |
| 202 | } |
| 203 | // update stats |
| 204 | w.stats.incKevts(evt) |
| 205 | w.stats.incBytes(uint64(l)) |
| 206 | w.stats.incProcs(evt) |
| 207 | case err := <-errs: |
| 208 | errsc <- err |
| 209 | eventSourceErrors.Add(1) |
| 210 | case <-w.stop: |
| 211 | return |
| 212 | } |
| 213 | } |
| 214 | }() |
| 215 | return errsc |
| 216 | } |
| 217 | |
| 218 | func (w *writer) write(b []byte) error { |
| 219 | w.mu.Lock() |
Callers
nothing calls this directly
Tested by
no test coverage detected