sharder

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultStorageConfig = StorageConfig{
		StorageType:            storageTypeDynamo,
		StorageRegion:          defaultRegion,
		StorageTable:           defaultTable,
		StorageTag:             defaultTag,
		UpdateFrequencySeconds: defaultUpdateFrequencySeconds,
		UpdateTtlSeconds:       defaultUpdateTtlSeconds,
		ForcedHostname:         defaultForcedHostname,
	}
)

Functions

func GetTaskArn added in v1.1.0

func GetTaskArn() (string, error)

func InitDistributorConfigs

func InitDistributorConfigs(config config.Config)

Types

type AWSTaskMetadata added in v1.1.0

type AWSTaskMetadata struct {
	TaskARN string
}

type Controller

type Controller struct {
	Distributor ShardDistributor
	ShardConfig
	StorageConfig map[string]interface{}
	sync.RWMutex
}

Controller represents persistence and work sharing elements

type ControllerConfig

type ControllerConfig struct {
	//Name string
	ShardConfig
	StorageConfig StorageConfig
	NodeName      string
}

ControllerConfig contains cluster and node based configuration data

func DefaultControllerConfig

func DefaultControllerConfig() *ControllerConfig

DefaultControllerConfig generates a default configuration based on a local dynamo instance

type NodeStateManager

type NodeStateManager interface {
	GetActiveNodes() ([]string, error)
	RemoveNode()
	Stop()
}

interface to get node state in the cluster

func GetDefaultNodeStateManager

func GetDefaultNodeStateManager(identity string, configData StorageConfig) (NodeStateManager, error)

type ShardConfig

type ShardConfig struct {
	Identity    string   `json:"identity"`
	NumShards   int      `json:"clusterShardNumber"`
	OwnedShards []string `json:"ownedShards"`
}

ShardConfig represents the shard ownership of each node

type ShardDistributor

type ShardDistributor interface {
	// Stop shuts down any resources used
	Stop()
	// Updates
	//return the ShardConfig channel
	Updates() ShardUpdater
	// Peers returns the list of healthy nodes
	Nodes() []string
	// Identity returns the identity of this node
	Identity() string
	// UpdateNumberShards sets a new number of shards, rehashes shards and publishes updates
	UpdateNumberShards(numShards int)
}

ShardDistributor defines

func GetDefaultHashDistributor

func GetDefaultHashDistributor(identity string, numShards int, configData StorageConfig) (ShardDistributor, error)

type ShardStatus

type ShardStatus struct {
	Shard      string `json:"shard"`
	LastPolled string `json:"lastPolledAt"`
}

ShardStatus represents a single shard's status

type ShardUpdater

type ShardUpdater chan ShardConfig

ShardUpdater will return a ShardConfig whenever the configuration changes

type SimpleHashDistributor

type SimpleHashDistributor struct {
	ShardConfig

	sync.Mutex
	// contains filtered or unexported fields
}

func (*SimpleHashDistributor) Identity

func (c *SimpleHashDistributor) Identity() string

Identity returns the note Identity that SimpleHashDistributor locate

func (*SimpleHashDistributor) Nodes

func (c *SimpleHashDistributor) Nodes() []string

Nodes returns list of nodes

func (*SimpleHashDistributor) Stop

func (c *SimpleHashDistributor) Stop()

Stop releases any resources

func (*SimpleHashDistributor) UpdateNumberShards

func (c *SimpleHashDistributor) UpdateNumberShards(numShards int)

func (*SimpleHashDistributor) Updates

func (c *SimpleHashDistributor) Updates() ShardUpdater

Updates returns the channel that SimpleHashDistributor will send ShardConfig updates on

type StorageConfig

type StorageConfig struct {
	StorageType            string
	StorageRegion          string
	StorageTable           string
	StorageTag             string
	UpdateFrequencySeconds int
	UpdateTtlSeconds       int
	ForcedHostname         string
}

Jump to

Keyboard shortcuts

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