route

package
v0.0.0-...-c2b34dc Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package route is designed for showing off the performance of the Google Cloud network you get when you use Compute Engine vms. It turns a GCE host and creates a path around the world from vm to vm that will pass an image around like postcard and stamp it with a png stamp for the area the machine in in.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoMoreToStamp is an error means there are no more entries in the
	// route that need stamping.
	ErrNoMoreToStamp = fmt.Errorf("There are no more entries to stamp")
	// ErrNoOpEntered is an error that means that an operation wasn't entered
	ErrNoOpEntered = fmt.Errorf("no operation selected")
	// ImagePath is the filesystem location where the images for stamping
	// are located
	ImagePath string
)

Functions

func GetImage

func GetImage(name string) (image.Image, error)

GetImage returns an image from the package pre loaded images. This allows us to only call images from the filesystem on startup

func NewID

func NewID(n int) string

NewID returns a randmomly generated ID string from each route.

Types

type Hop

type Hop struct {
	Origin      Node          `json:"origin,omitempty"`
	Destination Node          `json:"destination,omitempty"`
	Duration    time.Duration `json:"duration,omitempty"`
	Nanoseconds int64         `json:"nanoseconds,omitempty"`
	Seconds     float64       `json:"seconds,omitempty"`
}

Hop represents a path on the route form origin node to destination node.

func NewHop

func NewHop(o, d Node) Hop

NewHop returns a new hop for which we have done the math.

func (*Hop) CalculateDuration

func (h *Hop) CalculateDuration() error

CalculateDuration does the math for a hop.

type Host

type Host struct {
	Name     string `json:"name,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
	Private  string `json:"private,omitempty"`
}

Host represents the networking endpoints of an individual machine.

type Node

type Node struct {
	Host Host      `json:"host,omitempty"`
	In   time.Time `json:"in,omitempty"`
	Out  time.Time `json:"out,omitempty"`
	Slot int       `json:"slot,omitempty"`
}

Node is a stop along the route. It consists of a host and a time in and time out.

func (*Node) Done

func (n *Node) Done() bool

Done answers if the node has had the route pass through it yet.

type Route

type Route struct {
	ID          string `json:"ID,omitempty"`
	Nodes       []Node `json:"nodes,omitempty"`
	Hops        []Hop  `json:"hops,omitempty"`
	Total       Hop    `json:"total,omitempty"`
	Postcard    string `json:"postcard,omitempty"`
	Initialized bool
	AllNodes    []Node    `json:"allnodes,omitempty"`
	AllHops     []Hop     `json:"allhops,omitempty"`
	LastUpdate  time.Time `json:"lastupdate,omitempty"`
}

Route is the path we are passing through the network.

func (*Route) AddNode

func (r *Route) AddNode(n Node)

AddNode handles adding a Node to the route, and handles adding the Hop.

func (*Route) CalculateHops

func (r *Route) CalculateHops() error

CalculateHops spins through the nodes, and calculates the duration of all of the hops

func (*Route) CalculateLastHop

func (r *Route) CalculateLastHop() error

CalculateLastHop sets the duration of the last hop in the route.

func (*Route) CalculateTotal

func (r *Route) CalculateTotal() error

CalculateTotal generates a hop for the first to last node.

func (*Route) CalculateTransitTime

func (r *Route) CalculateTransitTime() float64

CalculateTransitTime does the math to figure out how long a set of Hops took based on their in and out times

func (*Route) ConvertAllNodesToHops

func (r *Route) ConvertAllNodesToHops()

func (*Route) CurrentNode

func (r *Route) CurrentNode(name string) int

CurrentNode will return the index of the current node we are working on

func (*Route) Done

func (r *Route) Done() bool

Done reports true when all of the nodes in the route are marked done.

func (*Route) JustStarted

func (r *Route) JustStarted() bool

JustStarted answers true if the route hasn't been passed around yet.

func (*Route) LastHop

func (r *Route) LastHop() int

LastHop returns the index of the last hop in the route.

func (*Route) LastStamp

func (r *Route) LastStamp() error

LastStamp should fire on the last hop that a route take, and adds total time to the picture.

func (*Route) MatteImage

func (r *Route) MatteImage() error

MatteImage places the image matte over the transmitted image.

func (*Route) Next

func (r *Route) Next() string

Next returns the next Node that to which we need to relay

func (*Route) Order

func (r *Route) Order() error

Order sets up a particular order for the route. australia-southeast1-a asia-east1-a asia-northeast1-a us-west1-a southamerica-east1-a us-central1-f us-east4-a europe-west2-b europe-west3-a

func (*Route) SetPostcard

func (r *Route) SetPostcard(img image.Image) error

SetPostcard sets the image in both encoded and binary version. For GRPC.

func (*Route) Shuffle

func (r *Route) Shuffle() error

Shuffle creates a route that has a random set of routes.

func (*Route) Stamp

func (r *Route) Stamp(io string) error

Stamp sets either the 'in' or 'out' timestamp on the route node.

func (*Route) StampImage

func (r *Route) StampImage(name string) error

StampImage takes the relayed postcard and adds a stamp image that corresponds with current host

func (*Route) UpdateHops

func (r *Route) UpdateHops() error

UpdateHops spins through the nodes, and calculates the duration of all of the hops

Jump to

Keyboard shortcuts

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