horizon

package module
v0.0.0-...-af321b4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

README

Horizon Network Service

This is the Horizon Network Service project. It provides the ability for individual agents to advertise and connect to other agents on a hosted set of network hubs.

It is explicitly designed for operational robustness via simplicity. For instance, the hub components can run when completely cut off from the control plane (called the central tier) and will gracefully rejoin when the control plane is restored.

It relies on S3 for long term, persistent service routing information.

Architectural Notes

Activity

There are 2 separate systems that involving passing information about events that have occured and both are named activity.

One passes data between central tier services using postgresql, by writing records to a table and issuing a postgresql NOTIFY command. This is used to flood routing updates on the control plane. Future work on the control plane may remove this system in favor of using a format messaging service, but for now it serves it's purpose fine and reduces the dependencies that the control plane has.

The second activity system is one used between central tier services and hubs. Hubs make a long running gRPC bidirectional stream connection to the central tier which is picked up by one of individual running instances. This stream is used to pass activity like routing updates but also statitics the hubs hold to the control plane.

Dev

To make development of the system easier, there is an explicit dev mode. First, run:

make dev-setup

This will create the PostgreSQL database, migrate it, and bring up the other services with docker-compose.

Next, you can run a control service node AND a hub in dev mode in the same process:

go run ./cmd/hzn/main.go dev

Next, you can connect an agent to this dev hub by specifying the control address as dev://localhost:24403. If you're connecting to the hub from docker, you should use dev://docker.for.mac.localhost:24403.

Ports

This setup exposes the services on the following ports:

  • 24401: Control server GRPC
  • 24402: Control server HTTP
  • 24403: Hub HZN protocol handler
  • 24404: Hub HTTP router
Tokens and IDs

The dev command writes 3 files that can be used to connect to them:

  • dev_agent-token.txt: A token to connect to the hub with
  • dev-agent-id.txt: The account ID tied to the auto created token
  • dev-mgmt-token.txt: A management client token that can be used to configure accounts, tokens, etc.
HTTP Routing

The easiest way to test the HTTP routing is to just fake a Host header. Here is an example of configuring a label-link and then sending the Hub's HTTP router a request:

# Run an agent that advertises an http service
$ go run ./cmd/hznagent agent --control dev://localhost:24403 --token "$(< dev-agent-token.txt)" --http 8081 --labels service=test,env=test --verbose

# Setup a label link from test.alpha.waypoint.run to the above labels
$ go run ./cmd/hznctl/main.go create-label-link --control-addr localhost:24401 --token "$(< dev-mgmt-token.txt)" --label :hostname=test.alpha.waypoint.run --account "$(< dev-agent-id.txt)" --target "service=test,env=test" --insecure

# Make a request to the HTTP routers with a Host header that matches the label link
$ curl -H "Host: test.alpha.waypoint.run" localhost:24404

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineLabels

func CombineLabels(a, b []agent.Label) []agent.Label

Types

This section is empty.

Directories

Path Synopsis
cmd
hzn
internal
httpassets
Package httpassets Code generated by go-bindata.
Package httpassets Code generated by go-bindata.
testsql
Package testsql provides helpers for working with PostgreSQL databases in unit tests, from creating per-test DBs to also running the migrations.
Package testsql provides helpers for working with PostgreSQL databases in unit tests, from creating per-test DBs to also running the migrations.
pkg
dbx
hub
pb
web
x

Jump to

Keyboard shortcuts

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