topology

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicOptions

type DynamicOptions interface {
	// Validate validates the options
	Validate() error

	// SetConfigServiceClient sets the client of ConfigService
	SetConfigServiceClient(c client.Client) DynamicOptions

	// ConfigServiceClient returns the client of ConfigService
	ConfigServiceClient() client.Client

	// SetServiceID sets the ServiceID for service discovery
	SetServiceID(s services.ServiceID) DynamicOptions

	// ServiceID returns the ServiceID for service discovery
	ServiceID() services.ServiceID

	// SetServicesOverrideOptions sets the override options for service discovery.
	SetServicesOverrideOptions(opts services.OverrideOptions) DynamicOptions

	// ServicesOverrideOptions returns the override options for service discovery.
	ServicesOverrideOptions() services.OverrideOptions

	// SetQueryOptions sets the ConfigService query options
	SetQueryOptions(value services.QueryOptions) DynamicOptions

	// QueryOptions returns the ConfigService query options
	QueryOptions() services.QueryOptions

	// SetInstrumentOptions sets the instrumentation options
	SetInstrumentOptions(value utils.Options) DynamicOptions

	// InstrumentOptions returns the instrumentation options
	InstrumentOptions() utils.Options
}

DynamicOptions is a set of options for dynamic topology

func NewDynamicOptions

func NewDynamicOptions() DynamicOptions

NewDynamicOptions creates a new set of dynamic topology options

type DynamicTopology

type DynamicTopology interface {
	Topology

	// MarkShardsAvailable marks a shard with the state of initializing as available
	MarkShardsAvailable(instanceID string, shardIDs ...uint32) error
}

DynamicTopology is a topology that dynamically changes and as such adds functionality for a clustered database to call back and mark a shard as available once it completes bootstrapping

type HealthTrackingDynamicTopoloy

type HealthTrackingDynamicTopoloy interface {
	Topology

	// MarkHostHealthy will keep the host in the view of Hosts
	MarkHostHealthy(host Host) error
	// MarkHostUnhealthy will remove the host from the view of Hosts
	MarkHostUnhealthy(host Host) error
}

HealthTrackingDynamicTopoloy is a topology that can set host healthiness and return a view with unhealthy hosts filtered out. Implementation of this interface should maintain a dynamic view of configured topology and delegate the responsibility of tracking host healthiness to the user.

func NewHealthTrackingDynamicTopology

func NewHealthTrackingDynamicTopology(opts DynamicOptions) (HealthTrackingDynamicTopoloy, error)

type Host

type Host interface {
	// ID is the identifier of the host
	ID() string

	// Address returns the address of the host
	Address() string

	// String returns a string representation of the host
	String() string
}

Host is a container of a host in a topology

func NewHost

func NewHost(id, address string) Host

NewHost creates a new host

type HostID

type HostID string

HostID is the string representation of a host ID.

type HostShardConfig

type HostShardConfig struct {
	HostID        string `yaml:"hostID"`
	ListenAddress string `yaml:"listenAddress"`
}

HostShardConfig stores host information for fanout

type HostShardSet

type HostShardSet interface {
	// Host returns the host
	Host() Host

	// ShardSet returns the shard set owned by the host
	ShardSet() shard.ShardSet
}

HostShardSet is a container for a host and corresponding shard set

func NewHostShardSet

func NewHostShardSet(host Host, shardSet aresShard.ShardSet) HostShardSet

NewHostShardSet creates a new host shard set

func NewHostShardSetFromServiceInstance

func NewHostShardSetFromServiceInstance(si services.ServiceInstance) (HostShardSet, error)

NewHostShardSetFromServiceInstance creates a new host shard set derived from a service instance

type HostShardState

type HostShardState struct {
	Host       Host
	ShardState m3Shard.State
}

HostShardState contains the state of a shard as owned by a given host.

type Initializer

type Initializer interface {
	// Init will return a new topology
	Init() (Topology, error)

	// TopologyIsSet returns whether the topology is able to be
	// initialized immediately or if instead it will blocked
	// wait to be set on initialization
	TopologyIsSet() (bool, error)
}

Initializer can init new instances of Topology

func NewDynamicInitializer

func NewDynamicInitializer(opts DynamicOptions) Initializer

NewDynamicInitializer returns a dynamic topology initializer

func NewStaticInitializer

func NewStaticInitializer(opts StaticOptions) Initializer

NewStaticInitializer creates a static topology initializer.

type Map

type Map interface {
	// Hosts returns all hosts in the map
	Hosts() []Host

	// HostShardSets returns all HostShardSets in the map
	HostShardSets() []HostShardSet

	// LookupHostShardSet returns a HostShardSet for a host in the map
	LookupHostShardSet(hostID string) (HostShardSet, bool)

	// HostsLen returns the length of all hosts in the map
	HostsLen() int

	// ShardSet returns the shard set for the topology
	ShardSet() shard.ShardSet

	// RouteShard will route a given shard to a set of hosts
	RouteShard(shard uint32) ([]Host, error)

	// Replicas returns the number of replicas in the topology
	Replicas() int
}

Map describes a placement

func NewStaticMap

func NewStaticMap(opts StaticOptions) Map

NewStaticMap creates Map

type MapProvider

type MapProvider interface {
	// TopologyMap returns a topology map.
	TopologyMap() (Map, error)
}

MapProvider is an interface that can provide a topology map.

type MapWatch

type MapWatch interface {
	// WatchChan is a notification channel when a value becomes available
	C() <-chan struct{}

	// Get the current placement map
	Get() Map

	// Close the watch on the placement map
	Close()
}

func NewMapWatch

func NewMapWatch(w xwatch.Watch) MapWatch

NewMapWatch creates MapWatch

type ShardID

type ShardID int

ShardID is the ID of a shard.

type ShardOwner

type ShardOwner interface {
	GetOwnedShards() []int
}

ShardOwner represents an entity that owned shards

func NewStaticShardOwner

func NewStaticShardOwner(shards []int) ShardOwner

NewStaticShardOwner returns shard owner that owns static shards

func NewTopologyShardOwner

func NewTopologyShardOwner(topo Topology) ShardOwner

NewTopologyShardOwner return a shard owner based on topology

type ShardStates

type ShardStates map[ShardID]map[HostID]HostShardState

ShardStates maps shard IDs to the state of each of the hosts that own that shard.

type StateSnapshot

type StateSnapshot struct {
	ShardStates ShardStates
}

StateSnapshot represents a snapshot of the state of the topology at a given moment.

type StaticConfiguration

type StaticConfiguration struct {
	Shards   int               `yaml:"shards"`
	Replicas int               `yaml:"replicas"`
	Hosts    []HostShardConfig `yaml:"hosts"`
}

StaticConfiguration is used for standing up M3DB with a static topology

type StaticOptions

type StaticOptions interface {
	// Validate validates the options
	Validate() error

	// SetShardSet sets the ShardSet
	SetShardSet(value shard.ShardSet) StaticOptions

	// ShardSet returns the ShardSet
	ShardSet() shard.ShardSet

	// SetHostShardSets sets the hostShardSets
	SetHostShardSets(value []HostShardSet) StaticOptions

	// HostShardSets returns the hostShardSets
	HostShardSets() []HostShardSet

	// SetReplicas sets the replicas
	SetReplicas(value int) StaticOptions

	// Replicas returns the replicas
	Replicas() int
}

StaticOptions is a set of options for static topology

func NewStaticOptions

func NewStaticOptions() StaticOptions

NewStaticOptions creates a new set of static topology options

type Topology

type Topology interface {
	// Get the placement setting map
	Get() Map

	// Watch for the placement setting map
	Watch() (MapWatch, error)

	// Close will close the placement setting map
	Close()
}

Topology is a container of a placement map and disseminates the placement map changes

func NewStaticTopology

func NewStaticTopology(opts StaticOptions) Topology

NewStaticTopology creates a static topology.

Directories

Path Synopsis
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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