schema

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteMessage

type DeleteMessage struct {
	BatchNumber uint
	DiskUUID    []byte
	WasRestored bool
}

Used internally to delete entries on the lazy disk chan

type EnqueueOptions

type EnqueueOptions struct {
	// ShouldEscalate is used to determine if the item should be escalated
	ShouldEscalate bool
	// EscalationRate is the time to wait before escalating the item (happens every duration)
	EscalationRate time.Duration
	// CanTimeout is used to determine if the item can timeout
	CanTimeout bool
	// Timeout is the time to wait before timing out the item
	Timeout time.Duration
}

EnqueueOptions is used to configure the EnQueue method

type GPQOptions

type GPQOptions struct {
	// Logger provides a custom logger interface for the Badger cache
	Logger badger.Logger
	// MaxPriority is the maximum priority allowed by this GPQ
	MaxPriority uint

	// DiskCacheEnabled is used to enable or disable the disk cache
	DiskCacheEnabled bool
	// DiskCachePath is the local path to the disk cache directory
	DiskCachePath string
	// DiskWriteDelay is the delay between writes to disk (used to batch writes)
	DiskWriteDelay time.Duration
	// DiskCacheCompression is used to enable or disable zstd compression on the disk cache
	DiskCacheCompression bool

	// LazyDiskCacheEnabled is used to enable or disable the lazy disk cache
	LazyDiskCacheEnabled bool
	// LazyDiskBatchSize is the number of items to write to disk at once
	LazyDiskBatchSize uint
	// LazyDiskCacheChannelSize is the length of the channel buffer for the disk cache
	LazyDiskCacheChannelSize uint

	// DiskEncryptionEnabled is used to enable or disable disk encryption
	DiskEncryptionEnabled bool
	// DiskEncryptionKey is the key used to encrypt the disk cache
	DiskEncryptionKey []byte
}

GPQOptions is used to configure the GPQ

type Item

type Item[d any] struct {
	// User
	Priority       uint
	Data           d
	DiskUUID       []byte
	ShouldEscalate bool
	EscalationRate time.Duration
	CanTimeout     bool
	Timeout        time.Duration

	// Internal
	SubmittedAt      time.Time
	LastEscalated    time.Time
	Index            int
	InternalPriority int
	BatchNumber      uint
	WasRestored      bool
}

Item is used to store items in the GPQ

func NewItem

func NewItem[d any](priority uint, data d, options EnqueueOptions) Item[d]

NewItem creates a new item using the options provide and data stored in a generic

func (*Item[d]) FromBytes

func (i *Item[d]) FromBytes(data []byte) error

FromBytes converts a blob to a item

func (*Item[d]) ToBytes

func (i *Item[d]) ToBytes() ([]byte, error)

ToBytes converts a item into a blob

Jump to

Keyboard shortcuts

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