diff options
| author | Christine Dodrill <me@christine.website> | 2018-07-01 20:38:18 +0000 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-07-01 20:38:18 +0000 |
| commit | 6197f455f695eb959a932e15dc417c1b50a2255b (patch) | |
| tree | eb90c08ea8e688894b033668587635c6e350f13d /vendor/github.com/Xe | |
| parent | b0e0b108231f9b71eebe68d8e9b99ca2846b4534 (diff) | |
| download | xesite-6197f455f695eb959a932e15dc417c1b50a2255b.tar.xz xesite-6197f455f695eb959a932e15dc417c1b50a2255b.zip | |
vgo
Diffstat (limited to 'vendor/github.com/Xe')
| -rw-r--r-- | vendor/github.com/Xe/gopreload/cmd/pluginizer/main.go | 56 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/database/mysql/main.go | 5 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/database/postgres/main.go | 5 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/database/sqlite3/main.go | 5 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/manhole/README.md | 56 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/manhole/server.go | 22 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/sample/main.go | 55 | ||||
| -rw-r--r-- | vendor/github.com/Xe/gopreload/sample/runtimeStatLogs/main.go | 36 | ||||
| -rw-r--r-- | vendor/github.com/Xe/ln/ex/doc.go | 7 | ||||
| -rw-r--r-- | vendor/github.com/Xe/ln/ex/gotrace.go | 68 | ||||
| -rw-r--r-- | vendor/github.com/Xe/ln/ex/http.go | 36 | ||||
| -rw-r--r-- | vendor/github.com/Xe/ln/ex/l2met.go | 25 | ||||
| -rw-r--r-- | vendor/github.com/Xe/ln/example/http.go | 51 |
13 files changed, 0 insertions, 427 deletions
diff --git a/vendor/github.com/Xe/gopreload/cmd/pluginizer/main.go b/vendor/github.com/Xe/gopreload/cmd/pluginizer/main.go deleted file mode 100644 index 67195a8..0000000 --- a/vendor/github.com/Xe/gopreload/cmd/pluginizer/main.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "os" - "path/filepath" - - _ "github.com/Xe/gopreload" -) - -var ( - pkgName = flag.String("pkg", "", "package to underscore import") - destPkgName = flag.String("dest", "", "destination package to generate") -) - -const codeTemplate = `//+build go1.8 - -package main - -import _ "$PACKAGE_PATH"` - -func main() { - flag.Parse() - - if *pkgName == "" || *destPkgName == "" { - log.Fatal("must set -pkg and -dest") - } - - srcDir := filepath.Join(os.Getenv("GOPATH"), "src", *destPkgName) - - err := os.MkdirAll(srcDir, os.ModePerm) - if err != nil { - log.Fatal(err) - } - - fout, err := os.Create(srcDir + "/main.go") - if err != nil { - log.Fatal(err) - } - defer fout.Close() - - codeBody := os.Expand(codeTemplate, func(s string) string { - if s == "PACKAGE_PATH" { - return *pkgName - } - - return "no idea man" - }) - - fmt.Fprintln(fout, codeBody) - - fmt.Println("To build this plugin: ") - fmt.Println(" $ go build -buildmode plugin -o /path/to/output.so " + *destPkgName) -} diff --git a/vendor/github.com/Xe/gopreload/database/mysql/main.go b/vendor/github.com/Xe/gopreload/database/mysql/main.go deleted file mode 100644 index 49042a9..0000000 --- a/vendor/github.com/Xe/gopreload/database/mysql/main.go +++ /dev/null @@ -1,5 +0,0 @@ -//+build go1.8 - -package main - -import _ "github.com/go-sql-driver/mysql" diff --git a/vendor/github.com/Xe/gopreload/database/postgres/main.go b/vendor/github.com/Xe/gopreload/database/postgres/main.go deleted file mode 100644 index 41efb5b..0000000 --- a/vendor/github.com/Xe/gopreload/database/postgres/main.go +++ /dev/null @@ -1,5 +0,0 @@ -//+build go1.8 - -package main - -import _ "github.com/lib/pq" diff --git a/vendor/github.com/Xe/gopreload/database/sqlite3/main.go b/vendor/github.com/Xe/gopreload/database/sqlite3/main.go deleted file mode 100644 index 7478b61..0000000 --- a/vendor/github.com/Xe/gopreload/database/sqlite3/main.go +++ /dev/null @@ -1,5 +0,0 @@ -//+build go1.8 - -package main - -import _ "github.com/mattn/go-sqlite3" diff --git a/vendor/github.com/Xe/gopreload/manhole/README.md b/vendor/github.com/Xe/gopreload/manhole/README.md deleted file mode 100644 index 4540449..0000000 --- a/vendor/github.com/Xe/gopreload/manhole/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# manhole - -An opinionated HTTP manhole into Go processes. - -## Assumptions This Package Makes - -- Make each server instance have a unique HTTP port that is randomized by default. - This makes it very hard to accidentally route this manhole to the outside world. - If more assurance is required I personally suggest using [yubikey totp][yktotp], - but do research. -- Application code does not touch [`http.DefaultServeMux`][default-servemux]'. This is so that - administative control rods can be dynamically flipped in the case they are - needed. -- [pprof][pprof] endpoints added to `http.DefaultServeMux`. This allows easy - access to [pprof runtime tracing][pprof-tracing] to debug issues on long-running - applications like HTTP services. -- Make the manhole slightly inconvenient to put into place in production. This - helps make sure that this tool remains a debugging tool and not a part of a - long-term production rollout. - -## Usage - -Compile this as a plugin: - -```console -$ go get -d github.com/Xe/gopreload/manhole -$ go build -buildmode plugin -o manhole.so github.com/Xe/gopreload/manhole -``` - -Then add [`gopreload`][gopreload] to your application: - -```go -// gopreload.go -package main - -/* - This file is separate to make it very easy to both add into an application, but - also very easy to remove. -*/ - -import _ "github.com/Xe/gopreload" -``` - -And at runtime add the `manhole.so` file you created earlier to the target system -somehow and add the following environment variable to its run configuration: - -```sh -GO_PRELOAD=/path/to/manhole.so -``` - ---- - -[pprof]: https://godoc.org/net/http/pprof -[default-servemux]: https://godoc.org/net/http#pkg-variables -[yktotp]: https://github.com/GeertJohan/yubigo -[gopreload]: https://github.com/Xe/gopreload diff --git a/vendor/github.com/Xe/gopreload/manhole/server.go b/vendor/github.com/Xe/gopreload/manhole/server.go deleted file mode 100644 index 1d542bc..0000000 --- a/vendor/github.com/Xe/gopreload/manhole/server.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "log" - "net" - "net/http" - _ "net/http/pprof" - "net/rpc" -) - -func init() { - l, err := net.Listen("tcp", "127.0.0.2:0") - if err != nil { - log.Printf("manhole: cannot bind to 127.0.0.2:0: %v", err) - return - } - - log.Printf("manhole: Now listening on http://%s", l.Addr()) - - rpc.HandleHTTP() - go http.Serve(l, nil) -} diff --git a/vendor/github.com/Xe/gopreload/sample/main.go b/vendor/github.com/Xe/gopreload/sample/main.go deleted file mode 100644 index b36bef2..0000000 --- a/vendor/github.com/Xe/gopreload/sample/main.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "fmt" - "math/rand" - "net/http" - "runtime" - "time" - - _ "github.com/Xe/gopreload" - "github.com/Xe/ln" -) - -func main() { - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - spew() - - ln.Log(ln.F{"action": "gc_spew", "who": r.RemoteAddr}) - - fmt.Fprintln(w, "done") - }) - - http.ListenAndServe(":9184", nil) -} - -func makeBuffer() []byte { - return make([]byte, rand.Intn(5000000)+5000000) -} - -func spew() { - pool := make([][]byte, 20) - - var m runtime.MemStats - makes := 0 - for _ = range make([]struct{}, 50) { - b := makeBuffer() - makes += 1 - i := rand.Intn(len(pool)) - pool[i] = b - - time.Sleep(time.Millisecond * 250) - - bytes := 0 - - for i := 0; i < len(pool); i++ { - if pool[i] != nil { - bytes += len(pool[i]) - } - } - - runtime.ReadMemStats(&m) - fmt.Printf("%d,%d,%d,%d,%d,%d\n", m.HeapSys, bytes, m.HeapAlloc, - m.HeapIdle, m.HeapReleased, makes) - } -} diff --git a/vendor/github.com/Xe/gopreload/sample/runtimeStatLogs/main.go b/vendor/github.com/Xe/gopreload/sample/runtimeStatLogs/main.go deleted file mode 100644 index ac530e0..0000000 --- a/vendor/github.com/Xe/gopreload/sample/runtimeStatLogs/main.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "runtime" - "time" - - "github.com/Xe/ln" -) - -func init() { - ln.Log(ln.F{ - "action": "started_up", - "every": "20_seconds", - "what": "gc_metrics", - }) - - go func() { - for { - time.Sleep(20 * time.Second) - gatherMetrics() - } - }() -} - -func gatherMetrics() { - stats := &runtime.MemStats{} - runtime.ReadMemStats(stats) - - ln.Log(ln.F{ - "gc-collections": stats.NumGC, - "gc-stw-pause-total": stats.PauseTotalNs, - "live-object-count": stats.Mallocs - stats.Frees, - "heap-bytes": stats.Alloc, - "stack-bytes": stats.StackInuse, - }) -} diff --git a/vendor/github.com/Xe/ln/ex/doc.go b/vendor/github.com/Xe/ln/ex/doc.go deleted file mode 100644 index 932ed42..0000000 --- a/vendor/github.com/Xe/ln/ex/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package ex is a set of extensions and middleware for ln. - -This package will (inevitably) have a lot of third-party dependencies and -as such might be broken apart into other packages in the future. -*/ -package ex diff --git a/vendor/github.com/Xe/ln/ex/gotrace.go b/vendor/github.com/Xe/ln/ex/gotrace.go deleted file mode 100644 index 5579879..0000000 --- a/vendor/github.com/Xe/ln/ex/gotrace.go +++ /dev/null @@ -1,68 +0,0 @@ -package ex - -import ( - "context" - "log" - - "github.com/Xe/ln" - "golang.org/x/net/trace" -) - -type goEventLogger struct { - ev trace.EventLog -} - -// NewGoEventLogger will log ln information to a given trace.EventLog instance. -func NewGoEventLogger(ev trace.EventLog) ln.Filter { - return &goEventLogger{ev: ev} -} - -func (gel *goEventLogger) Apply(ctx context.Context, e ln.Event) bool { - data, err := ln.DefaultFormatter.Format(ctx, e) - if err != nil { - log.Printf("wtf: error in log formatting: %v", err) - return false - } - - if everr := e.Data["err"]; everr != nil { - gel.ev.Errorf("%s", string(data)) - return true - } - - gel.ev.Printf("%s", string(data)) - return true -} - -func (gel *goEventLogger) Close() { gel.ev.Finish() } -func (gel *goEventLogger) Run() {} - -type sst string - -func (s sst) String() string { return string(s) } - -func goTraceLogger(ctx context.Context, e ln.Event) bool { - sp, ok := trace.FromContext(ctx) - if !ok { - return true // no trace in context - } - - data, err := ln.DefaultFormatter.Format(ctx, e) - if err != nil { - log.Printf("wtf: error in log formatting: %v", err) - return false - } - - if everr := e.Data["err"]; everr != nil { - sp.SetError() - } - - sp.LazyLog(sst(string(data)), false) - - return true -} - -// NewGoTraceLogger will log ln information to a golang.org/x/net/trace.Trace -// if it is present in the context of ln calls. -func NewGoTraceLogger() ln.Filter { - return ln.FilterFunc(goTraceLogger) -} diff --git a/vendor/github.com/Xe/ln/ex/http.go b/vendor/github.com/Xe/ln/ex/http.go deleted file mode 100644 index c5715a3..0000000 --- a/vendor/github.com/Xe/ln/ex/http.go +++ /dev/null @@ -1,36 +0,0 @@ -package ex - -import ( - "net" - "net/http" - "time" - - "github.com/Xe/ln" -) - -func HTTPLog(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - host, _, _ := net.SplitHostPort(r.RemoteAddr) - f := ln.F{ - "remote_ip": host, - "x_forwarded_for": r.Header.Get("X-Forwarded-For"), - "path": r.URL.Path, - } - ctx := ln.WithF(r.Context(), f) - st := time.Now() - - next.ServeHTTP(w, r.WithContext(ctx)) - - af := time.Now() - f["request_duration"] = af.Sub(st) - - ws, ok := w.(interface { - Status() int - }) - if ok { - f["status"] = ws.Status() - } - - ln.Log(r.Context(), f) - }) -} diff --git a/vendor/github.com/Xe/ln/ex/l2met.go b/vendor/github.com/Xe/ln/ex/l2met.go deleted file mode 100644 index e2a7f19..0000000 --- a/vendor/github.com/Xe/ln/ex/l2met.go +++ /dev/null @@ -1,25 +0,0 @@ -package ex - -import ( - "time" - - "github.com/Xe/ln" -) - -// This file deals with formatting of [l2met] style metrics. -// [l2met]: https://r.32k.io/l2met-introduction - -// Counter formats a value as a metrics counter. -func Counter(name string, value int) ln.Fer { - return ln.F{"count#" + name: value} -} - -// Gauge formats a value as a metrics gauge. -func Gauge(name string, value int) ln.Fer { - return ln.F{"gauge#" + name: value} -} - -// Measure formats a value as a metrics measure. -func Measure(name string, ts time.Time) ln.Fer { - return ln.F{"measure#" + name: time.Since(ts)} -} diff --git a/vendor/github.com/Xe/ln/example/http.go b/vendor/github.com/Xe/ln/example/http.go deleted file mode 100644 index 7fb98a3..0000000 --- a/vendor/github.com/Xe/ln/example/http.go +++ /dev/null @@ -1,51 +0,0 @@ -// +build ignore - -package main - -import ( - "context" - "flag" - "net/http" - "time" - - "github.com/Xe/ln" - "github.com/Xe/ln/ex" - "github.com/facebookgo/flagenv" - "golang.org/x/net/trace" -) - -var ( - port = flag.String("port", "2145", "http port to listen on") - tracingFamily = flag.String("trace-family", "ln example", "tracing family to use for x/net/trace") -) - -func main() { - flagenv.Parse() - flag.Parse() - - ln.DefaultLogger.Filters = append(ln.DefaultLogger.Filters, ex.NewGoTraceLogger()) - - http.HandleFunc("/", handleIndex) - http.ListenAndServe(":"+*port, middlewareSpan(ex.HTTPLog(http.DefaultServeMux))) -} - -func middlewareSpan(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - sp := trace.New(*tracingFamily, "HTTP request") - defer sp.Finish() - ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second) - defer cancel() - - ctx = trace.NewContext(ctx, sp) - - next.ServeHTTP(w, r.WithContext(ctx)) - }) -} - -func handleIndex(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - - ln.Log(ctx, ln.Action("index"), ln.F{"there_is": "no_danger"}) - - http.Error(w, "There is no danger citizen", http.StatusOK) -} |
