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

KAUCHE Loves Go

Yuki Ito
October 26, 2022

KAUCHE Loves Go

Yuki Ito

October 26, 2022
Tweet

More Decks by Yuki Ito

Other Decks in Programming

Transcript

  1. KAUCHE ❤ Go Yuki Ito (@mrno110) KAUCHE Tech Talk #3

  2. KAUCHE Platform Team: Architect Yuki Ito @mrno110

  3. https://gihyo.jp/book/2022/978-4-297-12519-6

  4. None
  5. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice
  6. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice
  7. Why Go? • Simplicity • Ecosystem • e.g. gRPC, google-cloud-go

    etc... • Used by Many Cloud Native Softwares • e.g. Kubernetes, Istio etc... • Goroutines & Channel
  8. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice
  9. Architecture Run Tasks Pub/Sub Mobile App External Service Mobile API

    Web Hook API Job API Scheduler
  10. https://cloud.withgoogle.com/next/speakers?session=HIVE101-JP

  11. Code Generation - gRPC gRPC is a modern open source

    high performance Remote Procedure Call (RPC) framework that can run in any environment. https://grpc.io/
  12. Code Generation - gRPC rpc GetProduct(GetProductRequest) returns (GetProductResponse) { option

    (google.api.http) = { get: "/..." }; } type CustomerServiceServer interface { GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error) // ... } Generate (protoc) Protocol Bu ff ers Go
  13. Code Generation - GraphQL GraphQL is a query language for

    APIs and a runtime for ful fi lling those queries with your existing data. https://graphql.org/
  14. Code Generation - GraphQL GraphQL Schema Generate (gqlgen) type QueryResolver

    interface { Products(ctx context.Context) ([]*Product, error) // ... } Go
  15. Code Generation - GraphQL https://github.com/99designs/gqlgen

  16. Code Generation - Database Fully managed relational database with unlimited

    scale, strong consistency, and up to 99.999% availability. https://cloud.google.com/spanner
  17. Code Generation - Database CREATE TABLE Products ( ProductId STRING(36)

    NOT NULL, -- ... ) PRIMARY KEY(ProductId); Database Schema Generate (yo) func FindProduct(ctx context.Context, db YORODB, productID string) (*Product, error) { // ... } Go
  18. Code Generation - Database cloudspannerecosystem / yo https://github.com/cloudspannerecosystem/yo

  19. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice
  20. Clean Architecture https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

  21. Clean Architecture • Entities • Business Objects • Use Cases

    • Application Business Rules • Drivers • gRPC • Cloud Spanner • Identity Platform • Event System • ...
  22. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice
  23. Architecture: 2020 ~ Run Customer App Customer gRPC

  24. Architecture: 2021 ~ Run Customer App Customer gRPC / Partner

    gRPC Partner App
  25. Modular Monolith Almost all the cases where I've heard of

    a system that was built as a microservice system from scratch, it has ended up in serious trouble. ... you shouldn't start a new project with microservices, even if you're sure your application will be big enough to make it worthwhile. MonolithFirst Martin Fowler https://martinfowler.com/bliki/MonolithFirst.html
  26. Modular Monolith ✅ Pros - Single Deployment Unit - Simple

    Design ❌ Cons - Independence - Autonomy
  27. Architecture: 2022 ~ Customer App Customer gRPC Partner App Partner

    gRPC API Gateway
  28. Architecture: 2022 ~ Commerce gRPC API Gateway Social GraphQL Customer

    GraphQL Federation (Apollo Router) Commerce GraphQL Social gRPC Platfrom Business
  29. Agenda • Why Go? • Go at KAUCHE • Code

    Generation • Clean Architecture • From Modular Monolith To Microservice