small pixel drawing of a pufferfish cascade

gofmt
Jes Olson j3s@c3f.net
Fri, 17 Feb 2023 19:41:04 -0800
commit

42a80faefcb2766140be7e8f323c8c806a5ee59a

parent

e32d6443754ec8e93d3136d22b35c06d1d975865

2 files changed, 18 insertions(+), 17 deletions(-)

jump to
M agent.goagent.go

@@ -2,7 +2,6 @@ package main

import ( "log" - "os" "sync" "time"

@@ -26,38 +25,34 @@ // This is the underlying Serf we are wrapping

serf *serf.Serf // this channel receiving a signal = shutdown - shutdown bool - shutdownCh chan struct{} + shutdown bool + shutdownCh chan struct{} shutdownLock sync.Mutex } -func Create(conf *Config, serfConf *serf.Config) (*Agent) { +func Create(conf *Config, serfConf *serf.Config) *Agent { // Create a channel to listen for events from Serf eventCh := make(chan serf.Event, 64) serfConf.EventCh = eventCh // Setup the agent agent := &Agent{ - conf: conf, - serfConf: serfConf, - eventCh: eventCh, - shutdownCh: make(chan struct{}), + conf: conf, + serfConf: serfConf, + eventCh: eventCh, + shutdownCh: make(chan struct{}), } return agent } -// setupAgent calls Create -func SetupAgent(config *Config) *Agent { +func setupAgent(config *Config) *Agent { bindIP, bindPort, err := config.AddrParts(config.BindAddr) if err != nil { log.Panic(err) } serfConfig := serf.DefaultConfig() - if os.Getenv("CASCADE_BIND") != "" { - config.BindAddr = os.Getenv("CASCADE_BIND") - } serfConfig.MemberlistConfig.BindAddr = bindIP serfConfig.MemberlistConfig.BindPort = bindPort serfConfig.MemberlistConfig.AdvertiseAddr = ""

@@ -77,7 +72,6 @@ serfConfig.TombstoneTimeout = 0

serfConfig.BroadcastTimeout = 0 // TODO: what are the implications of true here o_O serfConfig.EnableNameConflictResolution = true - // hardcode DefaultWANConfig because cascade is designed to be // used as a single global system.
M main.gomain.go

@@ -8,11 +8,18 @@ // dns resolver for services

package main -import "log" +import ( + "log" + "os" +) func main() { + c := DefaultConfig() + if os.Getenv("CASCADE_BIND") != "" { + c.BindAddr = os.Getenv("CASCADE_BIND") + } // agent does everything tbh - agent := SetupAgent(DefaultConfig()) + agent := setupAgent(c) log.Println(agent) -// agent.Run() + // agent.Run() }