Documentation
¶
Index ¶
- Variables
- func CheckArea(area Area, maxDepth float64, areasMap map[string]*Area, ...) error
- func CheckGeoCoordinates(coordinates GeoCoordinates) error
- func CheckInfrastructure(infrastructure Infrastructure) (map[string]*Area, error)
- func CheckNode(node Node) error
- func MarshalArea(area Area) ([]byte, error)
- func MarshalInfrastructure(infrastructure Infrastructure) ([]byte, error)
- func MarshalNode(node Node) ([]byte, error)
- func MarshallGeoCoordinates(coordinates GeoCoordinates) ([]byte, error)
- type Area
- type GeoCoordinates
- type Infrastructure
- type Node
- type Resources
Constants ¶
This section is empty.
Variables ¶
var ( ErrAreaMaxDepth = errors.New("area max depth reached") ErrAreaNodeNameUnique = errors.New("area name must be unique") ErrHostUnique = errors.New("host must be unique") )
Errors.
var ( // ErrGeoCoordinatesLongitude is returned when the longitude is not valid. ErrGeoCoordinatesLongitude = errors.New("longitude is not valid") // ErrGeoCoordinatesLatitude is returned when the latitude is not valid. ErrGeoCoordinatesLatitude = errors.New("latitude is not valid") )
var ( // ErrInfrastructureAreaIdentifiersUnique is returned when an node identifier is duplicated. ErrInfrastructureAreaIdentifiersUnique = errors.New("infrastructure node identifiers unique") // ErrInfrastructureAreaIdentifiersEmpty is returned when the Infrastructure has no node identifiers. ErrInfrastructureAreaIdentifiersEmpty = errors.New("infrastructure node identifiers empty") // ErrInfrastructureNodeIdentifierEmpty is returned when an node identifier is empty. ErrInfrastructureAreaIdentifierEmpty = errors.New("infrastructure node identifier empty") )
Errors.
var ( ErrAreaNameEmpty = errors.New("area name cannot be empty") ErrHostEmpty = errors.New("host cannot be empty") ErrLatitudeOutOfRange = errors.New("latitude out of range") ErrLongitudeOutOfRange = errors.New("longitude out of range") ErrResourceValueNegative = errors.New("resource value cannot be negative") )
Errors.
Functions ¶
func CheckArea ¶
func CheckArea(area Area, maxDepth float64, areasMap map[string]*Area, hostsMap map[string]bool) error
CheckArea checks the Area.
func CheckGeoCoordinates ¶
func CheckGeoCoordinates(coordinates GeoCoordinates) error
CheckGeoCoordinates checks if the GeoCoordinates are valid.
func CheckInfrastructure ¶
func CheckInfrastructure(infrastructure Infrastructure) (map[string]*Area, error)
CheckInfrastructure checks the Infrastructure.
func MarshalInfrastructure ¶
func MarshalInfrastructure(infrastructure Infrastructure) ([]byte, error)
MarshalInfrastructure marshals the Infrastructure.
func MarshallGeoCoordinates ¶
func MarshallGeoCoordinates(coordinates GeoCoordinates) ([]byte, error)
MarshallGeoCoordinates marshalls the GeoCoordinates.
Types ¶
type Area ¶
Struct that represents an Area.
func UnmarshalArea ¶
UnmarshalArea unmarshals the Area.
type GeoCoordinates ¶
type GeoCoordinates struct { Longitude float64 `json:"longitude"` Latitude float64 `json:"latitude"` }
func NewGeoCoordinates ¶
func NewGeoCoordinates(longitude float64, latitude float64) (*GeoCoordinates, error)
NewGeoCoordinates creates a new GeoCoordinates.
func UnmarshalGeoCoordinates ¶
func UnmarshalGeoCoordinates(data []byte) (*GeoCoordinates, error)
UnmarshalGeoCoordinates unmarshals the GeoCoordinates.
func (*GeoCoordinates) String ¶
func (g *GeoCoordinates) String() string
String returns the string representation of the GeoCoordinates.
type Infrastructure ¶
type Infrastructure struct { // Area identifiers are used to identify the hierarchy of areas. AreaIdentifiers []string `json:"areaIdentifiers"` // Areas are the hierarchy of areas. Areas []Area `json:"areas"` }
Struct that represents the entry point of the infrastructure.
func NewInfrastructure ¶
func NewInfrastructure(areaIdentifiers []string, areas []Area) (*Infrastructure, map[string]*Area, error)
NewInfrastructure creates a new Infrastructure.
func UnmarshalInfrastructure ¶
func UnmarshalInfrastructure(data []byte) (*Infrastructure, map[string]*Area, error)
UnmarshalInfrastructure unmarshals the Infrastructure.
func (*Infrastructure) Flatten ¶
func (i *Infrastructure) Flatten() []*Area
Returns the flatten list of areas.
func (*Infrastructure) String ¶
func (i *Infrastructure) String() string
String returns the string representation of the Infrastructure.
type Node ¶
type Node struct { // The name of the node. AreaName string `json:"areaName"` // The host of the node. Host string `json:"host"` // The geo coordinates of the node. GeoCoordinates GeoCoordinates `json:"geoCoordinates,omitempty"` // The resources of the node. Resources Resources `json:"resources,omitempty"` // The tags of the node. Tags map[string]string `json:"tags,omitempty"` }
Struct that represents the data of a node.
func NewNode ¶
func NewNode(areaName string, host string, geoCoordinates GeoCoordinates) (*Node, error)
NewNode creates a new node.
func UnmarshalNode ¶
UnmarshalNode unmarshals the node.