MCPcopy
hub / github.com/etcd-io/bbolt / executeRead

Function executeRead

concurrent_test.go:437–463  ·  view source on GitHub ↗
(tx *bolt.Tx, bucket []byte, key []byte, readInterval duration)

Source from the content-addressed store, hash-verified

435}
436
437func executeRead(tx *bolt.Tx, bucket []byte, key []byte, readInterval duration) (historyRecord, error) {
438 var rec historyRecord
439
440 b := tx.Bucket(bucket)
441
442 initialVal := b.Get(key)
443 time.Sleep(randomDurationInRange(readInterval.min, readInterval.max))
444 val := b.Get(key)
445
446 if !bytes.Equal(initialVal, val) {
447 return rec, fmt.Errorf("read different values for the same key (%q), value1: %q, value2: %q",
448 string(key), formatBytes(initialVal), formatBytes(val))
449 }
450
451 clonedVal := make([]byte, len(val))
452 copy(clonedVal, val)
453
454 rec = historyRecord{
455 OperationType: Read,
456 Bucket: string(bucket),
457 Key: string(key),
458 Value: clonedVal,
459 Txid: tx.ID(),
460 }
461
462 return rec, nil
463}
464
465func executeWrite(tx *bolt.Tx, bucket []byte, key []byte, writeBytes bytesRange, noopWriteRatio int) (historyRecord, error) {
466 var rec historyRecord

Callers 1

executeOperationFunction · 0.85

Calls 6

randomDurationInRangeFunction · 0.85
IDMethod · 0.80
formatBytesFunction · 0.70
ErrorfMethod · 0.65
BucketMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected