Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. • https://www.golang.org/ • Robert Griesemer, Rob Pike, Ken Thompson, Brad Fitzpatrick etc. • Open sourced on Nov 10, 2009 • Statically typed, compiled language, garbage collected
• Compiles crazy fast • Simple: 25 keywords • Good at concurrency: Channels, light-weight processes (goroutines) • Novel ideas: Interfaces are implicit, type embedding • Creates a static binary: No dependency headaches • Very good at cross-compiling • Solid standard library • Integrated package management system (without versioning) • Opinionated: No generics, no type inheritance, no method overloading, no operators, no exceptions, no pointer arithmetic.
for job := range jobs { fmt.Printf("Worker %d processing job %d\n", id, job) time.Sleep(time.Duration(rand.Int63n(1000)) * time.Millisecond) } } func main() { // Create buffered channel with up to 100 entries jobs := make(chan int, 100) // Start 3 workers for w := 1; w <= 3; w++ { go worker(w, jobs) } // Send data down the channel to the workers for j := 1; j <= 1000; j++ { jobs <-‐ j } close(jobs) } Concurrency in Go
about Go • Very intuitive and clean • Productive within days • Rob Pike and Ken Thompson obviously know a bit or two about programming • They have a mountain of experience, good taste, and solid opinions • They favor simplicity, minimalism, and clean code Recently on Hacker News: “I'm more surprised that the Go 1.4 compiler is written in C. Writing a compiler in C sounds very unpleasant compared to a language like OCaml. Does anyone know why they made this choice for the initial design?“ — “Ken Thompson wrote it. He's pretty good at C.“ Give Go a try e.g. by visiting the Go Tour at https://tour.golang.org/
Elasticsearch client for Go at the time of writing our code. So we wrote our own. We released it as open source last year. https://olivere.github.com/elastic (Home) https://github.com/olivere/elastic (Source)
"net/http" "github.com/olivere/elastic" ) func main() { // Get a client client, _ := elastic.NewClient(http.DefaultClient) // Get the version for some ES server version, _ := client.ElasticsearchVersion("http://127.0.0.1:9200") fmt.Printf("You're running Elasticsearch version %s", version) } Example: Determine Elasticsearch version
• The client exposes services, e.g. CreateIndex or Search • Services follow the "builder pattern" • Services have a Do method to execute • Follow the Java client API
Focus on search/data management, not on cluster/administration (for now) • APIs: 14 of 23 implemented • Query DSL: 26 of 39 • Filters: 20 of 27 • Facets: 9 of 9 • Aggregations: 28 of 29
string `json:"user"` Message string `json:"message"` } … // Create a new tweet tweet := Tweet{ User: "telexico", Message: "At the Elasticsearch meetup, having fun with the good people here.", } // Add document to Elasticsearch _, err = client.Index(). Index("test"). Type("tweet"). Id("1"). BodyJson(tweet). Do() if err != nil { panic(err) } fmt.Println("Document added") Example: Adding a document
Cars have GPS on board • Cars also offer tons of other data from gearbox, clutch, brakes etc. • We only need: • Latitude/Longitude • Speed • Steering wheel position
• „Racing App“ by GPSoverIP GmbH • Provides live car tracking over the Internet • Let’s write a proxy and record data into Elasticsearch Racing App: https://itunes.apple.com/de/app/racing-app/id444591012?mt=8
Elasticsearch • Run a program to track sector entry and exit times for the cars • Elasticsearch has strong Geo query capabilities that make this super simple • Make a nice PDF for the non-geeks
• Elasticsearch is a realtime document store • Elasticsearch is crazy fast • Elasticsearch has exhaustive query capabilities • GeoJSON for geo data • D3.js for visualization • How to run the Nordschleife in sub-9:30m