MCPcopy Index your code
hub / github.com/coder/coder / Upsert

Method Upsert

enterprise/coderd/connectionlog/connectionlog.go:195–208  ·  view source on GitHub ↗

Upsert enqueues a connection log entry for batched writing. It blocks if the internal buffer is full, ensuring no logs are dropped. It returns an error if the batcher or caller context is canceled.

(ctx context.Context, clog database.UpsertConnectionLogParams)

Source from the content-addressed store, hash-verified

193// blocks if the internal buffer is full, ensuring no logs are dropped.
194// It returns an error if the batcher or caller context is canceled.
195func (b *DBBatcher) Upsert(ctx context.Context, clog database.UpsertConnectionLogParams) error {
196 if b.ctx.Err() != nil {
197 return b.ctx.Err()
198 }
199
200 select {
201 case b.itemCh <- clog:
202 return nil
203 case <-b.ctx.Done():
204 return b.ctx.Err()
205 case <-ctx.Done():
206 return ctx.Err()
207 }
208}
209
210// Close cancels the batcher context, waits for the run loop and
211// retry worker to exit.

Callers 2

Test_batcherFlushFunction · 0.95
TestDBBackendIntegrationFunction · 0.95

Calls 2

ErrMethod · 0.80
DoneMethod · 0.45

Tested by 2

Test_batcherFlushFunction · 0.76
TestDBBackendIntegrationFunction · 0.76