manager

package
v0.0.0-...-f1e7488 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPlatformExists is returned when a platform for a provided selector exists. Used to prevent replacing
	// platforms.
	ErrPlatformExists = errors.New("platform already exists")
	// ErrPlatformNotFound is returned when a platform for a provided selector cannot be found.
	ErrPlatformNotFound = errors.New("platform not found")
	// ErrInvalidNewInput is returned when an invalid input is provided to a Manager implementation creation
	// function.
	ErrInvalidNewInput = errors.New("invalid NewMap input")
)

Functions

func GetSimulationPlatform

func GetSimulationPlatform(manager Manager, sim simulations.Simulation) (platform.Platform, error)

GetSimulationPlatform gets the platform.Platform associated with a simulation.

Types

type Manager

type Manager interface {
	// Selectors returns a slice with all the available platform selectors.
	Selectors() []string
	// Platforms returns a slice with all the available platforms.
	// The `selector` parameter can be passed to define a target platform. If `selector` is defined and a platform is
	// matched, the matched platform will be the first element in the returned list. If `target` is `nil` or is not
	// found, the elements in the list will be returned in random order.
	Platforms(selector *string) []platform.Platform
	// Platform returns the platform that matches a specific selector, or an error if it is not found.
	Platform(selector string) (platform.Platform, error)
}

Manager manages a platformMap of platforms that can be used by Cloudsim. Implementations must be simple platform containers and must not be aware of the feature sets, differences (if any) or implementation details of the available platforms they contain. This is by design, in order to give applications the flexibility to manage sets of platforms as they see fit. All contained platforms are completely independent from each other. As an example, you can have a platformMap of platforms that use the same internal components (e.g. AWS+Kubernetes), but that are configured to point to different service regions. At the same time, it is possible to have additional platforms making use of entirely different components (e.g. GCP+Mesos, Azure+Swarm) co-exist with the platformMap of AWS+Kubernetes platforms. Every platform is uniquely identified by a Selector, a user-defined identifier. To make use of a specific platform, the target platform's Selector is passed to the Manager implementation through the Platform method. An example of a selector platformMap:

  • aws_k8s_us_east_1 - Platform containing AWS and Kubernetes components pointed at us-east-1.
  • aws_k8s_us_east_2 - Platform containing AWS and Kubernetes components pointed at us-east-2.
  • gcp_mesos - Platform containing GCE and Apache Mesos components.
  • azure_swarm - Platform containing Azure and Docker Swarm components.

func NewMapFromConfig

func NewMapFromConfig(input *NewInput) (Manager, error)

NewMapFromConfig loads a platformMap of platforms from a configuration file and returns a platform Map containing the platforms.

func WithRoundRobin

func WithRoundRobin(base Manager) (Manager, error)

WithRoundRobin initializes a new Manager using a base platform Manager but iterates over the inner manager using round robin.

type Map

type Map map[string]platform.Platform

Map is the default Manager implementation.

func (Map) Platform

func (m Map) Platform(selector string) (platform.Platform, error)

Platform receives a selector and returns its matching platform or an error if it is not found.

func (Map) Platforms

func (m Map) Platforms(selector *string) []platform.Platform

Platforms returns a slice with all the available platforms.

func (Map) Selectors

func (m Map) Selectors() []string

Selectors returns a slice with all the available platform selectors.

type NewInput

type NewInput struct {
	// ConfigPath contains the path to the platforms configuration file.
	// If this field is an empty string, it will default to the `config.yaml` file in the directory Cloudsim is running
	// in.
	ConfigPath string
	// Loader used to load the configuration file
	Loader loader.Loader
	// Logger used to configure platforms.
	Logger ign.Logger
}

NewInput contains common information necessary to create a new manager implementation instance. Manager implementations should use or embed this structure to request input data.

Jump to

Keyboard shortcuts

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