Skip to content

Instantly share code, notes, and snippets.

View thrawn01's full-sized avatar
🎯
Focusing

Derrick J. Wippler thrawn01

🎯
Focusing
View GitHub Profile
@thrawn01
thrawn01 / workerpool.go
Last active June 15, 2020 23:08
Simple WorkerPool Implementation
package main
import (
"io"
"log"
"net"
_ "net/http/pprof"
"strings"
"sync"
"sync/atomic"
@thrawn01
thrawn01 / printf-array-scan.go
Created May 12, 2020 15:34
Take []byte output from printing with fmt.Printf("%v", myBytes) and convert it back into a golang []byte
package main
import (
"fmt"
"strings"
)
func main() {
// [ and ] have been manually removed
s := "76 105 99 32 83 105 110 100 105 97 32 78 117 241"
client := http.Client{
Transport: &http2.Transport{
// So http2.Transport doesn't complain the URL scheme isn't 'https'
AllowHTTP: true,
// Pretend we are dialing a TLS endpoint.
// Note, we ignore the passed tls.Config
DialTLSContext: func(ctx context.Context, n, a string, _ *tls.Config) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, n, a)
},
server := http2.Server{}
l, err := net.Listen("tcp", "0.0.0.0:1010")
checkErr(err, "while listening")
fmt.Printf("Listening [0.0.0.0:1010]...\n")
for {
conn, err := l.Accept()
checkErr(err, "during accept")
@thrawn01
thrawn01 / h2c-server.go
Last active April 19, 2024 20:32
How to add h2c support to existing HTTP/2 HTTP/1 servers
h2s := &http2.Server{}
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil)
})
server := &http.Server{
Addr: "0.0.0.0:1010",
Handler: h2c.NewHandler(handler, h2s),
}
@thrawn01
thrawn01 / account-stats.md
Last active January 30, 2019 17:40
Account Stats API Proposal

Account Totals by Domain


This API allows customers to retrieve a single count for a every domain in their account. This allows customers to identify domains based on a stat. (IE: Most active, Most Bounces, etc..)

GET /accounts/totals

Parameter | Description

@thrawn01
thrawn01 / main.go
Created December 3, 2018 20:34
etcd `concurrency.Election` example with connection interruption detection and initial leadership status reporting
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"time"
@thrawn01
thrawn01 / main.go
Last active December 3, 2018 20:28
Illustrate ResumeElection issue
package main
import (
"context"
"fmt"
"os"
"time"
"strings"
etcd "github.com/coreos/etcd/clientv3"
diff --git a/cmd/start.go b/cmd/start.go
index 0666e58..b7aa35b 100644
--- a/cmd/start.go
+++ b/cmd/start.go
@@ -96,7 +96,7 @@ func runConfig(ctx *cli.Context, r *util.RuntimeEnv) error {
r.Exec("minikube", "config", "set", "cpus", ctx.String("cpus"))
r.Exec("minikube", "config", "set", "disk-size", ctx.String("disk"))
r.Exec("minikube", "config", "set", "vm-driver", r.VirtDriver)
- r.Exec("minikube", "config", "set", "kubernetes-version", ctx.String("k8s-version"))
+ //r.Exec("minikube", "config", "set", "kubernetes-version", ctx.String("k8s-version"))

Time Spent

  • 17.30% - events.Parse() Parsing JSON events
  • 15.05% - eventbus-go.grpcEventFetcher() Reading events from kafka-pixy
  • 10.44% - counter.updateWorker() flushing counter cache to C*
  • 3.73% - counter.Bump() incrementing counter cache
  • 5.52% - gocql.recv() handles async responses from C*
  • 6.74% - grpc/transport.reader() handles async responses? Runs in separate go-routine!

Top Malloc users

  1. easyjson.Unmarshal()