util

package
v0.0.0-...-1b33b2a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddingKeySpan = KeySpanStatus(iota) + 1
	RemovingKeySpan
	RunningKeySpan
)

Variables

This section is empty.

Functions

func SortKeySpanIDs

func SortKeySpanIDs(keyspanIDs []model.KeySpanID)

SortKeySpanIDs sorts a slice of keyspan IDs in ascending order.

Types

type KeySpanRecord

type KeySpanRecord struct {
	KeySpanID model.KeySpanID
	CaptureID model.CaptureID
	Status    KeySpanStatus
}

keyspanRecord is a record to be inserted into keyspanSet.

func (*KeySpanRecord) Clone

func (r *KeySpanRecord) Clone() *KeySpanRecord

Clone returns a copy of the KeySpanSet. This method is future-proof in case we add something not trivially copyable.

type KeySpanSet

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

KeySpanSet provides a data structure to store the keyspans' states for the scheduler.

func NewKeySpanSet

func NewKeySpanSet() *KeySpanSet

NewKeySpanSet creates a new KeySpanSet.

func (*KeySpanSet) AddKeySpanRecord

func (s *KeySpanSet) AddKeySpanRecord(record *KeySpanRecord) (successful bool)

AddKeySpanRecord inserts a new KeySpanRecord. It returns true if it succeeds. Returns false if there is a duplicate.

func (*KeySpanSet) CountKeySpanByCaptureID

func (s *KeySpanSet) CountKeySpanByCaptureID(captureID model.CaptureID) int

CountKeySpanByCaptureID counts the number of keyspans associated with the captureID.

func (*KeySpanSet) CountKeySpanByStatus

func (s *KeySpanSet) CountKeySpanByStatus(status KeySpanStatus) (count int)

CountKeySpanByStatus counts the number of keyspans with the given status.

func (*KeySpanSet) GetAllKeySpans

func (s *KeySpanSet) GetAllKeySpans() map[model.KeySpanID]*KeySpanRecord

GetAllKeySpans returns all stored information on all keyspans.

func (*KeySpanSet) GetAllKeySpansGroupedByCaptures

func (s *KeySpanSet) GetAllKeySpansGroupedByCaptures() map[model.CaptureID]map[model.KeySpanID]*KeySpanRecord

GetAllKeySpansGroupedByCaptures returns all stored information grouped by associated CaptureID.

func (*KeySpanSet) GetDistinctCaptures

func (s *KeySpanSet) GetDistinctCaptures() []model.CaptureID

GetDistinctCaptures counts distinct captures with keyspans.

func (*KeySpanSet) GetKeySpanRecord

func (s *KeySpanSet) GetKeySpanRecord(keyspanID model.KeySpanID) (*KeySpanRecord, bool)

GetKeySpanRecord tries to obtain a record with the specified keyspanID.

func (*KeySpanSet) RemoveKeySpanRecord

func (s *KeySpanSet) RemoveKeySpanRecord(keyspanID model.KeySpanID) bool

RemoveKeySpanRecord removes the record with keyspanID. Returns false if none exists.

func (*KeySpanSet) RemoveKeySpanRecordByCaptureID

func (s *KeySpanSet) RemoveKeySpanRecordByCaptureID(captureID model.CaptureID) []*KeySpanRecord

RemoveKeySpanRecordByCaptureID removes all keyspan records associated with captureID.

func (*KeySpanSet) UpdateKeySpanRecord

func (s *KeySpanSet) UpdateKeySpanRecord(record *KeySpanRecord) (successful bool)

UpdateKeySpanRecord updates an existing KeySpanRecord. All modifications to a keyspan's status should be done by this method.

type KeySpanStatus

type KeySpanStatus int32

KeySpanStatus is a type representing the keyspan's replication status.

Jump to

Keyboard shortcuts

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