Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Golang @ eureka

Golang @ eureka

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

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

Tweet

More Decks by Masashi Salvador Mitsuzawa

Other Decks in Technology

Transcript

  1. Golang @ eureka
    Masashi Salvador Mitsuzawa

    View Slide

  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

    View Slide

  3. - Members
    - 50 engineers
    - 54 non engineers

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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)

    View Slide

  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

    View Slide

  10. But We love
    - new language
    - challenging
    - creating new standard
    - at the same time engineers’ growing up

    View Slide

  11. then we chose Go

    View Slide

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

    View Slide

  13. Microservices
    EJBHSBNESBXOCZ!LBOFTIJO

    View Slide

  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)

    View Slide

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

    View Slide

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

    View Slide

  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)

    View Slide

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

    View Slide

  19. go generate
    - go generate

    View Slide

  20. go generate
    - go generate

    View Slide

  21. go generate
    - handing with routing
    - gin default (from README.md)
    - how to handle with many routing and controllers?

    View Slide

  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

    View Slide

  23. go generate
    - in routes_gen.go
    - generator/main.go: pattern written in go template

    View Slide

  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

    View Slide

  25. package vendoring
    - glide (current)
    - glide get github.com/hogehoge/fugafuga
    - glide install

    View Slide

  26. ginkgo -> standard library
    - Why NOT ginkgo?
    - heavy
    - Rspec Syntax
    - JustBeforeEach, BeforeEach, JustBefore, Before
    - not like Golang
    - members’ unfamiliar with RSpec
    - Standard testing + testify

    View Slide

  27. Mines …
    - Default Values
    - Slice append
    - packaging (unfamiliar with LL lang users)
    - gophers love bare net/http too much :)

    View Slide

  28. Thank you :)

    View Slide