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 ¶
- Variables
- func GetImage(name string) (image.Image, error)
- func NewID(n int) string
- type Hop
- type Host
- type Node
- type Route
- func (r *Route) AddNode(n Node)
- func (r *Route) CalculateHops() error
- func (r *Route) CalculateLastHop() error
- func (r *Route) CalculateTotal() error
- func (r *Route) CalculateTransitTime() float64
- func (r *Route) ConvertAllNodesToHops()
- func (r *Route) CurrentNode(name string) int
- func (r *Route) Done() bool
- func (r *Route) JustStarted() bool
- func (r *Route) LastHop() int
- func (r *Route) LastStamp() error
- func (r *Route) MatteImage() error
- func (r *Route) Next() string
- func (r *Route) Order() error
- func (r *Route) SetPostcard(img image.Image) error
- func (r *Route) Shuffle() error
- func (r *Route) Stamp(io string) error
- func (r *Route) StampImage(name string) error
- func (r *Route) UpdateHops() error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 (*Hop) CalculateDuration ¶
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.
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) CalculateHops ¶
CalculateHops spins through the nodes, and calculates the duration of all of the hops
func (*Route) CalculateLastHop ¶
CalculateLastHop sets the duration of the last hop in the route.
func (*Route) CalculateTotal ¶
CalculateTotal generates a hop for the first to last node.
func (*Route) CalculateTransitTime ¶
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 ¶
CurrentNode will return the index of the current node we are working on
func (*Route) JustStarted ¶
JustStarted answers true if the route hasn't been passed around yet.
func (*Route) LastStamp ¶
LastStamp should fire on the last hop that a route take, and adds total time to the picture.
func (*Route) MatteImage ¶
MatteImage places the image matte over the transmitted image.
func (*Route) Order ¶
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 ¶
SetPostcard sets the image in both encoded and binary version. For GRPC.
func (*Route) StampImage ¶
StampImage takes the relayed postcard and adds a stamp image that corresponds with current host
func (*Route) UpdateHops ¶
UpdateHops spins through the nodes, and calculates the duration of all of the hops