small pixel drawing of a pufferfish cascade

api -> http
Jes Olson j3s@c3f.net
Mon, 20 Feb 2023 18:00:11 -0800
commit

2d61578f336b9f69e87747b987752dc22461b427

parent

d5f6f0e1717c95843e148cc6df98d08e9747ad49

3 files changed, 15 insertions(+), 13 deletions(-)

jump to
M agent/agent.goagent/agent.go

@@ -22,6 +22,8 @@ // - for simplicity, operability, and because gossip can handle it

// compatability // - attempt to have a consul-compatible API where it matters? // todo +// think about checks +// think about DNS weights // dns resolver for services // read-write exception for maintenance mode? // opentelemetry metrics
M agent/config.goagent/config.go

@@ -6,8 +6,8 @@ "os"

) const ( - DefaultAPIPort int = 8500 DefaultDNSPort int = 8600 + DefaultHTTPPort int = 8500 DefaultSerfPort int = 8301 )

@@ -19,8 +19,8 @@ }

// TODO: figure out how to default the listeners cfg := Config{} - cfg.APIBindAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: DefaultAPIPort} cfg.DNSBindAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: DefaultDNSPort} + cfg.HTTPBindAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: DefaultHTTPPort} cfg.SerfBindAddr = &net.TCPAddr{IP: net.ParseIP("0.0.0.0"), Port: DefaultSerfPort} cfg.NodeName = hostname

@@ -28,8 +28,8 @@ return &cfg

} type Config struct { - APIBindAddr *net.TCPAddr DNSBindAddr *net.TCPAddr + HTTPBindAddr *net.TCPAddr SerfBindAddr *net.TCPAddr NodeName string StartJoin []string
M command/agent/agent.gocommand/agent/agent.go

@@ -26,12 +26,12 @@ for basically everything, including service registration,

health checking, cluster membership, and hosting the API. options: - -bind-api=<addr> - address the http api binds to (default = 127.0.0.1:8500) - -bind-dns=<addr> address the DNS server binds to (default = 127.0.0.1:8600) + -bind-http=<addr> + address the http api/interace binds to (default = 127.0.0.1:8500) + -bind-serf=<addr> address the serf agent binds to (default = 0.0.0.0:8301)

@@ -43,8 +43,8 @@ name of this node, must be globally unique (default = hostname)

` type Flags struct { - bindAPI string bindDNS string + bindHTTP string bindSerf string join string node string

@@ -55,8 +55,8 @@

func Run(args []string) { flags := flag.NewFlagSet("agent", flag.ContinueOnError) flags.Usage = func() { fmt.Printf(usage) } - flags.StringVar(&agentFlags.bindAPI, "bind-api", "", "") flags.StringVar(&agentFlags.bindDNS, "bind-dns", "", "") + flags.StringVar(&agentFlags.bindHTTP, "bind-http", "", "") flags.StringVar(&agentFlags.bindSerf, "bind-serf", "", "") flags.StringVar(&agentFlags.join, "join", "", "") flags.StringVar(&agentFlags.node, "node", "", "")

@@ -156,13 +156,14 @@ // getAgentConfig takes a default agent config and modifies it based

// on user specified flags. It also does some a little input validation. func getAgentConfig() (*agent.Config, error) { config := agent.DefaultConfig() - if agentFlags.bindAPI != "" { - if err := parseFlagAddress(agentFlags.bindAPI, config.APIBindAddr); err != nil { + + if agentFlags.bindDNS != "" { + if err := parseFlagAddress(agentFlags.bindDNS, config.DNSBindAddr); err != nil { return nil, err } } - if agentFlags.bindDNS != "" { - if err := parseFlagAddress(agentFlags.bindDNS, config.DNSBindAddr); err != nil { + if agentFlags.bindHTTP != "" { + if err := parseFlagAddress(agentFlags.bindHTTP, config.HTTPBindAddr); err != nil { return nil, err } }

@@ -171,7 +172,6 @@ if err := parseFlagAddress(agentFlags.bindSerf, config.SerfBindAddr); err != nil {

return nil, err } } - if agentFlags.join != "" { // TODO: moar validation config.StartJoin = strings.Split(agentFlags.join, ",")