diff options
| author | Christine Dodrill <me@christine.website> | 2018-10-04 18:04:48 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-10-04 18:04:48 -0700 |
| commit | fbedf4acda9ff659a69fe577465db9617ec94ba1 (patch) | |
| tree | 74c0e72a1380a431813c78eb688b5b93db72800a /cmd | |
| parent | 51b60f36ac286c973dd258571b77db24e9ace031 (diff) | |
| download | x-fbedf4acda9ff659a69fe577465db9617ec94ba1.tar.xz x-fbedf4acda9ff659a69fe577465db9617ec94ba1.zip | |
remove vendored dependencies for some things, vgo is coming
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/ghettoscale/main.go | 42 | ||||
| -rw-r--r-- | cmd/ghettoscale/redis.go | 27 | ||||
| -rw-r--r-- | cmd/ghettoscale/scale.go | 75 |
3 files changed, 0 insertions, 144 deletions
diff --git a/cmd/ghettoscale/main.go b/cmd/ghettoscale/main.go deleted file mode 100644 index 8ad78c6..0000000 --- a/cmd/ghettoscale/main.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "context" - "flag" - "net/url" - "os" - "time" - - "github.com/Xe/ln" - _ "github.com/joho/godotenv/autoload" -) - -var ( - every = flag.Duration("every", 10*time.Minute, "how often this binary is being run") - do = flag.Int("do", 1, "do this number of scale checks, staggered by -every") -) - -func main() { - flag.Parse() - ctx := context.Background() - ctx = ln.WithF(ctx, ln.F{"at": "main"}) - - pool, err := NewRedisPoolFromURL(os.Getenv("REDIS_URL")) - if err != nil { - ln.FatalErr(ctx, err) - } - _ = pool - - for _, a := range flag.Args() { - ln.Log(ctx, ln.F{"url": a}) - u, err := url.Parse(a) - if err != nil { - ln.FatalErr(ctx, err) - } - - err = Check(ctx, u) - if err != nil { - ln.FatalErr(ctx, err) - } - } -} diff --git a/cmd/ghettoscale/redis.go b/cmd/ghettoscale/redis.go deleted file mode 100644 index 94375c0..0000000 --- a/cmd/ghettoscale/redis.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "time" - - "github.com/garyburd/redigo/redis" -) - -// NewRedisPoolFromURL returns a new *redigo/redis.Pool configured for th1e supplied url -// The url can include a password in the standard form and if so is used to AUTH against -// the redis server. -func NewRedisPoolFromURL(url string) (*redis.Pool, error) { - return &redis.Pool{ - MaxIdle: 3, - IdleTimeout: 240 * time.Second, - Dial: func() (redis.Conn, error) { - return redis.DialURL(url) - }, - TestOnBorrow: func(c redis.Conn, t time.Time) error { - if time.Since(t) < time.Minute { - return nil - } - _, err := c.Do("PING") - return err - }, - }, nil -} diff --git a/cmd/ghettoscale/scale.go b/cmd/ghettoscale/scale.go deleted file mode 100644 index fa503f8..0000000 --- a/cmd/ghettoscale/scale.go +++ /dev/null @@ -1,75 +0,0 @@ -package main - -import ( - "context" - "fmt" - "net/url" -) - -// State is the state of the ghetto autoscaler. -type State int - -/* -States that this can be in - - digraph G { - ok [label="OK"] - scaling_up [label="Scaling Up"] - scaling_down [label="Scaling Down"] - max_scale [label="Max Scale"] - - init -> ok [label="test passes"] - init -> scaling_up [label="test fails"] - ok -> scaling_up [label="test fails"] - scaling_up -> scaling_up [label="test fails"] - scaling_up -> max_scale [label="test fails"] - scaling_up -> ok [label="test passes"] - scaling_down -> ok [label="minimum\nscale"] - ok -> scaling_down [label="test has\npassed\nn times"] - scaling_down -> scaling_down [label="test passes"] - max_scale -> scaling_down [label="test passes"] - max_scale -> ok [label="test passes"] - } - -This is the overall state machine for the autoscaler. -*/ -const ( - Init State = iota - OK - ScalingUp - MaxScale - ScalingDown -) - -func Check(ctx context.Context, u *url.URL) error { - switch u.Scheme { - case "heroku": - return CheckHeroku(ctx, u) - } - - return fmt.Errorf("no such scheme for %s", u.Scheme) -} - -func CheckHeroku(ctx context.Context, u *url.URL) error { - // q := u.Query() - var err error - - // heroku://printerfacts/web?kind=lang&metric=g:go.routines_max&min=1&max=3&stagger=1&mode=threshold&threshold=500 - // appID := u.Host - // processType := u.Path[1:] - // kind := q.Get("kind") - // metric := q.Get("metric") - // min := q.Get("min") - // max := q.Get("max") - // stagger := q.Get("stagger") - // mode := q.Get("mode") - - // get redis connection - // check if app:process type is currently staggered in redis - // if so decrement stagger counter in redis and exit - // fetch metrics data from metrics-api - // fetch current number of dynos for this app id and process type - // fetch state of the - - return err -} |
