Skip to content

Instantly share code, notes, and snippets.


Aaron Schlesinger arschles

View GitHub Profile
arschles / log_entry.go
Last active Sep 11, 2018
Threading Log Entries Down the Stack in Athens
View log_entry.go
func newLogEntry(req *http.Request, lggr *log.Logger) logrus.Entry {
return lggr.WithFields(logrus.Fields{
"http-method": req.Method,
"http-path": req.URL.Path,
"http-url": req.URL.String(),
arschles / keep-cool-with-fans.go
Last active Aug 28, 2018
Fan-out and Fan-in with Go
View keep-cool-with-fans.go
package fans
// this code was inspired by
// it uses the context package (which wasn't available when that presentation was made) instead of a timer to
// do timeouts
import (
arschles /
Last active Aug 28, 2018
Tuning an HTTP Client for Great Good!

Other Go Libraries to Help With Doing HTTP Clients

  • ctxhttp - use HTTP clients but do requests timeouts with a context
    • httptrace - a good library to pair with ctxhttp; you can use this to trace requests up to the server. this is pretty advanced usage, so I recommend you go here once you have basic performance issues sorted out
  • fasthttp - slightly easier-to-use HTTP client. you still have to deal with connection pool details though. still useful if you like the API better
  • go-cleanhttp - battle-tested HTTP client. useful to compare against the above code
  • gorequest - nicer API, not as geared toward load testing. recommend against this for load tests, but for business logic it's good
arschles /
Created Aug 15, 2018
Running athens tests
make dev-teardown
export GO_BINARY_PATH=go1.11rc1
make alldeps
# sleep a little more
sleep 5
buffalo db create
buffalo db migrate up
make test-unit
arschles / buffalo_actions_test.go
Last active Jul 10, 2018
Sample Buffalo Test
View buffalo_actions_test.go
package actions
// this is a test method. It needs to have the prefix "Test"
func (a *ActionSuite) TestSomething() {
// this gives you one of these:
// you can also use a.Assert() to get one of these:
r := a.Require()
// this gets you a completely empty DB with all the schemas and migrations already run on it.
arschles /
Last active May 18, 2018
Cloud Native PDX May 17 2018 Demo Commands
echo "OSBA (the broker for Azure) and service-catalog (the adapter for Kubernetes) are installed:"
helm list
echo "we also have a cool catalog of services we can create and hook up to:"
kubectl get clusterserviceclasses
echo "that's lame ... let's use svcat to see a friendly version:"
svcat get classes
arschles /
Created Aug 16, 2017
SIG-Service-Catalog LGTM Policy Retro 8/17/2017

This PR was merged on July 19, 2017:

In the thread on that PR, both jdumars and I suggested that we try the change out and then have a retrospective on how that change has affected:

  1. Our ability to actively get a PR merged
  2. The quality of the project over the month of the LGTM policy as of this PR

I'll be facilitating an initial 15 minute retrospective.

If you have opinions on either of those topics, please bring them to present at this meeting. I am going to focus this discussion on opinions backed up with data that show trends over the 7/19 - 8/17 time frame.

arschles /
Last active Dec 7, 2016
Finalizer Example for Binding Objects
  name: my-binding
  namespace: default
    - kubernetes # a default
    - # custom
    - # custom
arschles / for_select.go
Last active Oct 17, 2016
for/select loop for tickers & timers
View for_select.go
i := 0
for {
select {
case <- timer.C:
case <-ticker.C:
arschles / chan-over-chan.go
Created Sep 9, 2016
Sending a channel over a channel
View chan-over-chan.go
package main
import (
type acker struct {
ch chan time.Duration