logbuffer

package
v0.0.0-...-f6902ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 29

Documentation

Index

Constants

View Source
const (
	Clean                   int32 = 0
	NeedsCleaning                 = 1
	PartitionCount                = 3
	LogMetaDataSectionIndex       = PartitionCount

	TermMinLength int32 = 64 * 1024

	LogMetaDataLength = pageMinSize
)
View Source
const Filename string = "logbuffers.bin"
View Source
const (
	// FrameAlignment frame alignment
	FrameAlignment int32 = 32
)

Variables

View Source
var DataFrameHeader = struct {
	FrameLengthFieldOffset   int32
	VersionFieldOffset       int32
	FlagsFieldOffset         int32
	TypeFieldOffset          int32
	TermOffsetFieldOffset    int32
	SessionIDFieldOffset     int32
	StreamIDFieldOffset      int32
	TermIDFieldOffset        int32
	ReservedValueFieldOffset int32
	DataOffset               int32

	Length int32

	TypePad   uint16
	TypeData  uint16
	TypeNAK   uint16
	TypeSM    uint16
	TypeErr   uint16
	TypeSetup uint16
	TypeExt   uint16

	CurrentVersion int8
}{
	0,
	4,
	5,
	6,
	8,
	12,
	16,
	20,
	24,
	32,

	32,

	0x00,
	0x01,
	0x02,
	0x03,
	0x04,
	0x05,
	0xFFFF,

	0x0,
}

Functions

func ComputeMaxMessageLength

func ComputeMaxMessageLength(capacity int32) int32

func FrameFlags

func FrameFlags(logBuffer *atomic.Buffer, frameOffset int32, flags uint8)

func GetFlags

func GetFlags(logBuffer *atomic.Buffer, frameOffset int32) uint8

func GetFrameLength

func GetFrameLength(logBuffer *atomic.Buffer, frameOffset int32) int32

func GetReservedValue

func GetReservedValue(logBuffer *atomic.Buffer, frameOffset int32) int64

func GetSessionId

func GetSessionId(logBuffer *atomic.Buffer, frameOffset int32) int32

func GetStreamId

func GetStreamId(logBuffer *atomic.Buffer, frameOffset int32) int32

func GetTermId

func GetTermId(logBuffer *atomic.Buffer, frameOffset int32) int32

func IsPaddingFrame

func IsPaddingFrame(logBuffer *atomic.Buffer, frameOffset int32) bool

func RemoveTestingLogbufferFile

func RemoveTestingLogbufferFile() error

RemoveTestingLogbufferFile is meant to be called by defer immediately after creating it above.

func RotateLog

func RotateLog(logMetaDataBuffer *LogBufferMetaData, currentTermCount int32, currentTermId int32)

func SetFrameLength

func SetFrameLength(logBuffer *atomic.Buffer, frameOffset int32, frameLength int32)

func SetFrameType

func SetFrameType(logBuffer *atomic.Buffer, frameOffset int32, typ uint16)

func TermID

func TermID(rawTail int64) int32

Types

type Claim

type Claim struct {
	// contains filtered or unexported fields
}

func (*Claim) Abort

func (claim *Claim) Abort()

Abort a claim of the message space to the log buffer so that the log can progress by ignoring this claim.

func (*Claim) Buffer

func (claim *Claim) Buffer() *atomic.Buffer

The referenced buffer to be used.

@return the referenced buffer to be used..

func (*Claim) Commit

func (claim *Claim) Commit()

Commit the message to the log buffer so that is it available to subscribers.

func (*Claim) Length

func (claim *Claim) Length() int32

The length of the claimed range in the buffer.

@return length of the range in the buffer.

func (*Claim) Offset

func (claim *Claim) Offset() int32

offset in the buffer at which the claimed range begins.

@return offset in the buffer at which the range begins.

func (*Claim) ReservedValue

func (claim *Claim) ReservedValue() int64

Get the value stored in the reserve space at the end of a data frame header.

Note: The value is in {@link ByteOrder#LITTLE_ENDIAN} format.

@return the value stored in the reserve space at the end of a data frame header. @see DataHeaderFlyweight

func (*Claim) SetReservedValue

func (claim *Claim) SetReservedValue(value int64) *Claim

Write the provided value into the reserved space at the end of the data frame header.

Note: The value will be written in {@link ByteOrder#LITTLE_ENDIAN} format.

@param value to be stored in the reserve space at the end of a data frame header. @return this for fluent API semantics. @see DataHeaderFlyweight

func (*Claim) Wrap

func (c *Claim) Wrap(buf *atomic.Buffer, offset, length int32)
type Header struct {
	// contains filtered or unexported fields
}

func (*Header) Flags

func (hdr *Header) Flags() uint8

func (*Header) FrameLength

func (hdr *Header) FrameLength() int32

func (*Header) GetReservedValue

func (hdr *Header) GetReservedValue() int64

func (*Header) InitialTermId

func (hdr *Header) InitialTermId() int32

func (*Header) Offset

func (hdr *Header) Offset() int32

func (*Header) Position

func (hdr *Header) Position() int64

Position calculates the current position to which the image has advanced on reading this message.

func (*Header) SessionId

func (hdr *Header) SessionId() int32

func (*Header) SetInitialTermID

func (hdr *Header) SetInitialTermID(initialTermID int32) *Header

func (*Header) SetOffset

func (hdr *Header) SetOffset(offset int32) *Header

func (*Header) SetPositionBitsToShift

func (hdr *Header) SetPositionBitsToShift(positionBitsToShift int32) *Header

func (*Header) SetReservedValue

func (hdr *Header) SetReservedValue(reservedValue int64) *Header

func (*Header) SetSessionId

func (hdr *Header) SetSessionId(value int32) *Header

func (*Header) StreamId

func (hdr *Header) StreamId() int32

func (*Header) TermId

func (hdr *Header) TermId() int32

func (*Header) Wrap

func (hdr *Header) Wrap(ptr unsafe.Pointer, length int32) *Header

type LogBufferMetaData

type LogBufferMetaData struct {
	flyweight.FWBase

	TailCounter        []flyweight.Int64Field // 0, 8, 16
	ActiveTermCountOff flyweight.Int32Field   // 24

	EndOfStreamPosOff       flyweight.Int64Field // 128
	IsConnected             flyweight.Int32Field // 136
	ActiveTransportCountOff flyweight.Int32Field // 140

	CorrelationId      flyweight.Int64Field // 256
	InitTermID         flyweight.Int32Field // 264
	DefaultFrameHdrLen flyweight.Int32Field // 270
	MTULen             flyweight.Int32Field // 274
	TermLen            flyweight.Int32Field // 278
	PageSize           flyweight.Int32Field // 282

	DefaultFrameHeader flyweight.RawDataField // 384
	// contains filtered or unexported fields
}

LogBufferMetaData is the flyweight for LogBuffer meta data * <pre> * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Tail Counter 0 | * | | * +---------------------------------------------------------------+ * | Tail Counter 1 | * | | * +---------------------------------------------------------------+ * | Tail Counter 2 | * | | * +---------------------------------------------------------------+ * | Active Term Count | * +---------------------------------------------------------------+ * | Cache Line Padding ... * ... | * +---------------------------------------------------------------+ * | End of Stream Position | * | | * +---------------------------------------------------------------+ * | Is Connected | * +---------------------------------------------------------------+ * | Cache Line Padding ... * ... | * +---------------------------------------------------------------+ * | Registration / Correlation ID | * | | * +---------------------------------------------------------------+ * | Initial Term Id | * +---------------------------------------------------------------+ * | Default Frame Header Length | * +---------------------------------------------------------------+ * | MTU Length | * +---------------------------------------------------------------+ * | Term Length | * +---------------------------------------------------------------+ * | Page Size | * +---------------------------------------------------------------+ * | Cache Line Padding ... * ... | * +---------------------------------------------------------------+ * | Default Frame Header ... * ... | * +---------------------------------------------------------------+ * </pre>

func (*LogBufferMetaData) ActiveTransportCount

func (m *LogBufferMetaData) ActiveTransportCount() int32

ActiveTransportCount returns the count of active transports for the Image.

func (*LogBufferMetaData) Wrap

func (m *LogBufferMetaData) Wrap(buf *atomic.Buffer, offset int) flyweight.Flyweight

type LogBuffers

type LogBuffers struct {
	// contains filtered or unexported fields
}

LogBuffers is the struct providing access to the file or files representing the terms containing the ring buffer

func NewTestingLogbuffer

func NewTestingLogbuffer() (*LogBuffers, error)

NewTestingLogbuffer is a helper function to create a new memmap file and logbuffer to wrap it.

func Wrap

func Wrap(fileName string) *LogBuffers

Wrap is the factory method wrapping the LogBuffers structure around memory mapped file

func (*LogBuffers) Buffer

func (logBuffers *LogBuffers) Buffer(index int) *atomic.Buffer

Buffer returns a buffer backing a specific term based on index. PartitionLength+1 is the size of the buffer array, and the last buffer is the metadata buffer, which can be accessed through a convenience wrapped via Meta() method.

func (*LogBuffers) Close

func (logBuffers *LogBuffers) Close() error

Close will try to unmap all backing memory maps

func (*LogBuffers) DecRef

func (logBuffers *LogBuffers) DecRef() int

DecRef decrements the reference count. Returns the current reference counter after decrement.

func (*LogBuffers) IncRef

func (logBuffers *LogBuffers) IncRef() int

IncRef increments the reference count. Returns the current reference count after increment.

func (*LogBuffers) Meta

func (logBuffers *LogBuffers) Meta() *LogBufferMetaData

Meta return log buffer meta data flyweight

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL