partition

package
v0.0.0-...-dd9be88 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoPartitionDataAvailableYet is returned by the SRV-aware
	// partition detector to indicate that SRV records for this target
	// application are not yet available.
	ErrNoPartitionDataAvailableYet = xerrors.Errorf("no partition data available yet")
)

Functions

This section is empty.

Types

type Detector

type Detector interface {
	PartitionInfo() (int, int, error)
}

Detector is implemented by types that can assign a clustered application instance to a particular partition.

type Fixed

type Fixed struct {
	// The assigned partition number.
	Partition int

	// The number of partitions.
	NumPartitions int
}

Fixed is a dummy PartitionDetector implementation that always returns back the same partition details.

func (Fixed) PartitionInfo

func (det Fixed) PartitionInfo() (int, int, error)

PartitionInfo implements PartitionDetector.

type FromSRVRecords

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

FromSRVRecords detects the number of partitions by performing an SRV query and counting the number of results.

func DetectFromSRVRecords

func DetectFromSRVRecords(srvName string) FromSRVRecords

DetectFromSRVRecords returns a PartitionDetector implementation that extracts the current partition name from the current host name and attempts to detect the total number of partitions by performing an SRV query and counting the number of responses.

This detector is meant to be used in conjunction with a Stateful Set in a kubernetes environment.

func (FromSRVRecords) PartitionInfo

func (det FromSRVRecords) PartitionInfo() (int, int, error)

PartitionInfo implements PartitionDetector.

type Range

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

Range represents a contiguous UUID region which is split into a number of partitions.

func NewFullRange

func NewFullRange(numPartitions int) (Range, error)

NewFullRange creates a new range that uses the full UUID value space and splits it into the provided number of partitions.

func NewRange

func NewRange(start, end uuid.UUID, numPartitions int) (Range, error)

NewRange creates a new range [start, end) and splits it into the provided number of partitions.

func (Range) PartitionExtents

func (r Range) PartitionExtents(partition int) (uuid.UUID, uuid.UUID, error)

PartitionExtents returns the [start, end) range for the requested partition.

Jump to

Keyboard shortcuts

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