allegro / allegro/bigcache

rationale behind `minimumHeaderSize` in `bytes_queue` package

Aperta
#284 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
8.2k
Fork
614
Merge medio
5g 12h
PR unite (30g)
1

Descrizione

To understand the issue take a look at this test:
```Go
func TestBytesQueue(t *testing.T) {
// given
queue := NewBytesQueue(10, 10, true)

// when
queue.Push([]byte("hello"))
queue.Push([]byte("m"))
queue.Pop()
_, err := queue.Push([]byte("o"))
if err != nil {
// test will fail here
// queueError{"Full queue. Maximum size limit reached."}
t.Fatal("Queue should have pushed `o`")
}

// then
// expected result
assertEqual(t, 2, queue.Len())
}
```
Clearly, the buffer has enough space to add `[]byte("o")`. Specifically, `canInsertBeforeHead` method should return true, but `minimumHeaderSize` prevents this to happen.
I am curious to know about the rationale behind `minimumHeaderSize` because as you saw it prevents testing/using this package intuitively.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.