Pro Yearly is on sale from $80 to $50! »

Golang @ eureka

Golang @ eureka

04/11
実践Go言語勉強会〜サービス導入している3社がGo言語の魅力をお伝えします〜
https://atnd.org/events/75883

the use of Golang at eureka (including tips, architecture)

Tweet

Transcript

  1. Golang @ eureka Masashi Salvador Mitsuzawa

  2. about eureka - pairs - over 3,500,000 users - Japan

    & Taiwan 12೥9݄ 13೥3݄ 13೥9݄ 14೥3݄ 14೥9݄ 15೥3݄ 225ສ 135ສ 45ສ 90ສ 190ສ 3.5 year over 3,500,000
  3. - Members - 50 engineers - 54 non engineers

  4. about me - Masashi Salvador Mitsuzawa - Senior Engineer @

    eureka - Monetization Team Leader / Server Side Engineer Leader - Love #Curry #Haskell #Golang #Algorithm #MachineLearning - see : #ΧϨʔ৯͏ͨΊʹੜ͖ͯΔ @instagram - Twitter: @MasashiSalvador - Major : Computational Neuroscience @ Graduate School - 2013 - 2015 DeNA - 2015 - current eureka
  5. Outline • Why Go? • Architecture of pairs • Microservices

    • Structure of application • Libraries • Golang TIPS in pairs
  6. Outline • Why Go? • Architecture of pairs • Microservices

    • Structure of application • Libraries • Golang TIPS in pairs
  7. pairs: - About pairs Go Project - Over 1 year

    project - Data migration (schema change) - Full-scratch the entire codebase - Background - huge tech debt (including design debt) - Monolith architecture - DB (unscalable / strange schema) - Tightly Coupled - Technical Challenge
  8. Why Go? - Minimum syntax (minimum Spec)
 - bundle with

    formatter - easy to learn - able to keep clean codebase - easy to read! (important : able to read all OSS code) - Static Typing - Safe - High Performance - Concurrency - goroutine / channel - Good Standard Libraries (net/http, database/sql)
  9. Why NOT Go? - No “Modern” Syntax - map /

    reduce - No Class syntax - No Exception - Less established Libraries and frameworks - WAF(gin? revel? beego? echo?) - testing - ORM
  10. But We love - new language - challenging - creating

    new standard - at the same time engineers’ growing up
  11. then we chose Go

  12. Outline • Why Go? • Architecture of pairs • Microservices

    • Structure of application • Libraries • Golang TIPS in pairs
  13. Microservices EJBHSBNESBXOCZ!LBOFTIJO

  14. Microservices - Service Oriented Architecture (All written in Golang) -

    pairs.lv - admin - search - batch - payment - surveillance - Stack - gin(pairs.lv) / goji(payment) - Elasticsearch - MySQL - Redis(cache) / DynamoDB - Ansible(provision, build, deploy)
  15. Response Request Structure Controller Facade Service Repository Entity - Basically

    structured as MVC Libraries View URL routing JSON SPA AngularJS + TypeScript DB
  16. Response Request Structure Controller Facade Service Repository Entity - Basically

    structured as MVC Libraries View URL routing JSON SPA AngularJS + TypeScript DB Core Library
  17. Libraries - WAF - revel (previous) - gin (current) -

    DB migration - goose - ORM - xorm - testing - ginkgo (RSpec Like / previous) - Go standard + testify (current) - package vendoring - nuts (previous) - glide (current)
  18. Outline • Why Go? • Architecture of pairs • Microservices

    • Structure of application • Libraries • Golang TIPS in pairs
  19. go generate - go generate

  20. go generate - go generate

  21. go generate - handing with routing - gin default (from

    README.md) - how to handle with many routing and controllers?
  22. go generate - handing with routing - naively (like many

    WAFs) main.go config/route mapping URL -> controller - a way to realize it in Go generator/main.go routes/api_xxx_v1.tml api_yyy_v1.tml api_zzz_v1.tml Read Read app/main_gen.go routes_gen.go Generate
  23. go generate - in routes_gen.go - generator/main.go: pattern written in

    go template
  24. package vendoring - nuts (previous) eure/eure-go cloned from repositories pinned

    commit-hash app.go go get github.com/eure/eure-go
 import “github.com/eure/eure-go/ vendor/_nuts/github.com/revel/revel" import
  25. package vendoring - glide (current) - glide get github.com/hogehoge/fugafuga -

    glide install
  26. ginkgo -> standard library - Why NOT ginkgo? - heavy

    - Rspec Syntax - JustBeforeEach, BeforeEach, JustBefore, Before - not like Golang - members’ unfamiliar with RSpec - Standard testing + testify
  27. Mines … - Default Values - Slice append - packaging

    (unfamiliar with LL lang users) - gophers love bare net/http too much :)
  28. Thank you :)