Documentation
¶
Overview ¶
Package ringtest holds CGo test helpers for the ring object.
They drive the C ring writer, hold extra references and link module configs to rings. Their C code is built by meson with the ring object archive's cache line size. Only tests import this package.
Index ¶
- func LinkRing(moduleConfigPtr unsafe.Pointer, name string) error
- func StressRecordValid(seqno uint32, payload []byte) bool
- type Reference
- type Stress
- type Writer
- func (m *Writer) CommitRecord(payload []byte) (uint32, error)
- func (m *Writer) CorruptTotalLen(logicalOffset uint64, totalLen uint32)
- func (m *Writer) Object() unsafe.Pointer
- func (m *Writer) Publish()
- func (m *Writer) SetIndices(write, readable uint64)
- func (m *Writer) Source() (cring.RecordSource, error)
- func (m *Writer) StartStress(records uint64) (*Stress, error)
- func (m *Writer) WriteRecord(payload []byte) (uint32, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LinkRing ¶
LinkRing links a module config, given as a raw pointer, to the named ring object.
It calls the C module link function directly.
func StressRecordValid ¶
StressRecordValid reports whether a payload is exactly the one the stress writer wrote for the given sequence number.
Types ¶
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference is an extra reference to a published ring.
It plays the role of a live generation that has not retired yet.
type Stress ¶
type Stress struct {
// contains filtered or unexported fields
}
Stress runs the C writer at full speed on its own OS thread.
The writer publishes by the ring's publish batch. Each record's length and bytes come from its sequence number, so a reader can detect a torn record.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer runs the C writer functions on one worker's ring.
It finds the ring through a raw object pointer.
func NewPublishedWriter ¶
NewPublishedWriter returns a Writer for one worker of the ring published under the given name.
It finds the ring the way the service that owns it publishes it.
func NewWriter ¶
NewWriter returns a Writer for one worker of a ring object, given as a raw pointer.
func (*Writer) CommitRecord ¶
CommitRecord adds one record to the unpublished batch and returns its sequence number.
Readers see the record after the next Publish. The ring may also publish the batch on its own: when this record fills the publish batch, or when the batch would grow too large. When the record does not fit the ring, CommitRecord returns an error and writes nothing, like the C writer.
func (*Writer) CorruptTotalLen ¶
CorruptTotalLen overwrites the length in the frame at a logical offset.
A test uses it to get a corrupt frame without a real race with the writer.
func (*Writer) Publish ¶
func (m *Writer) Publish()
Publish makes every record committed since the last publication visible to readers.
func (*Writer) SetIndices ¶
SetIndices sets the write and readable positions.
It sets both the writer's own copies and the published ones. A test uses it to start near the physical end or with a backlog, without writing records to get there.
func (*Writer) Source ¶
func (m *Writer) Source() (cring.RecordSource, error)
Source returns the production record source of this writer's worker.
So a test reads records the same way a real reader does.
func (*Writer) StartStress ¶
StartStress starts writing the given number of records to the writer's worker ring.
The ring publishes them by its own publish batch. The writer stops early if the ring refuses a record.