Skip to content

Instantly share code, notes, and snippets.

@tedsuo
tedsuo / log_jammer.go
Created July 17, 2015 17:25
Log Jammer App
package main
import (
"fmt"
"log"
"net/http"
"os"
"strconv"
"time"
)
@tedsuo
tedsuo / volman_feedback.md
Last active February 2, 2016 18:57
Volman Feedback

volman/cmd/volman/main.go

Don't dot import.

parse flags in init instead of main - not a big deal but a better practice.

passing loggers - logger argument always comes first in every function that takes a logger

exitOnFailure() - use log.Fatal to trigger a log and panic instead

@tedsuo
tedsuo / exec.go
Created March 5, 2016 01:03
ifrit.Exec
package ifrit
import (
"os"
"os/signal"
)
const SIGNAL_BUFFER_SIZE = 1024
func Exec(logger Logger, runner Runner, signalTypes ...os.Signal) {
@tedsuo
tedsuo / 1-bank.go
Last active March 7, 2016 08:22
Why golang favors code generation for protocols
// When writing an application, we want to stick to the details that are specific
// to our application domain. We don't want to write generic code that deals with
// contemporary issues, such as "what type of client would like to connect to us today?"
package bank
// The Account interface represents our application's protocol.
// We'd like to never have to write the generic transport protocol code.
type Account interface{
HowFarInTheHoleAmI() Farthings
}
@tedsuo
tedsuo / main_v1.go
Last active August 7, 2018 20:00
ifrit v2: Cleanup and simplification of boilerplate in main
// Old clunky way of setting up ifrit
package main
import ...
func main() {
logger := newLogger("example-service")
members := grouper.Members{
{"http_server", httpServer},
@tedsuo
tedsuo / trace_lager.go
Last active August 18, 2016 18:02
Adding OpenTracing to Lager
func FromContext(context.Context) Logger {}
func FromSpan(opentracing.Span) Logger {}
func FromHTTPHeaders(http.Header) Logger {}
func ToHTTPHeaders(Logger, http.Header) {}
type Logger interface {
// Lifecycle
@tedsuo
tedsuo / client.go
Created August 26, 2016 15:26
Example Cell API v1.0
package cell
import "io"
type Client interface {
Query(QueryRequest) (QueryResponse, error)
Allocate(AllocationRequest) (AllocationResponse, error)
Run(RunRequest) (RunResponse, error)
Stop(StopRequest) (StopResponse, error)
Delete(DeleteRequest) (DeleteResponse, error)
@tedsuo
tedsuo / ot-rc1.md
Last active September 14, 2017 18:39
ot-rc1

Scope Proposal Release Candidate 1

This Release Candidate proposes an approach to managed Span propagation without enforcing Span lifetime handling through (in-code) reference counting.

Release Candidate objectives

  • Decouple active Span propagation from Span.finish().
  • Remove ActiveSpan/ActiveSpanManager reference counting.

Approach

@tedsuo
tedsuo / excerpt.md
Last active June 9, 2018 01:09
An Excerpt from "Letter from a Birmingham Jail"

I must make two honest confessions to you, my Christian and Jewish brothers. First, I must confess that over the past few years I have been gravely disappointed with the white moderate. I have almost reached the regrettable conclusion that the Negro's great stumbling block in his stride toward freedom is not the White Citizen's Counciler or the Ku Klux Klanner, but the white moderate, who is more devoted to "order" than to justice; who prefers a negative peace which is the absence of tension to a positive peace which is the presence of justice; who constantly says: "I agree with you in the goal you seek, but I cannot agree with your methods of direct action"; who paternalistically believes he can set the timetable for another man's freedom; who lives by a mythical concept of time and who constantly advises the Negro to wait for a "more convenient season." Shallow understanding from people of good will is more frustrating than absolute misunderstanding from people of ill will. Lukewarm acceptance is much more