Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

KAUCHE Platform Team: Architect Yuki Ito @mrno110

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Why Go? • Simplicity • Ecosystem • e.g. gRPC, google-cloud-go etc... • Used by Many Cloud Native Softwares • e.g. Kubernetes, Istio etc... • Goroutines & Channel

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Architecture Run Tasks Pub/Sub Mobile App External Service Mobile API Web Hook API Job API Scheduler

Slide 10

Slide 10 text

https://cloud.withgoogle.com/next/speakers?session=HIVE101-JP

Slide 11

Slide 11 text

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/

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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/

Slide 14

Slide 14 text

Code Generation - GraphQL GraphQL Schema Generate (gqlgen) type QueryResolver interface { Products(ctx context.Context) ([]*Product, error) // ... } Go

Slide 15

Slide 15 text

Code Generation - GraphQL https://github.com/99designs/gqlgen

Slide 16

Slide 16 text

Code Generation - Database Fully managed relational database with unlimited scale, strong consistency, and up to 99.999% availability. https://cloud.google.com/spanner

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Code Generation - Database cloudspannerecosystem / yo https://github.com/cloudspannerecosystem/yo

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Clean Architecture https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

Slide 21

Slide 21 text

Clean Architecture • Entities • Business Objects • Use Cases • Application Business Rules • Drivers • gRPC • Cloud Spanner • Identity Platform • Event System • ...

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

Architecture: 2020 ~ Run Customer App Customer gRPC

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Modular Monolith ✅ Pros - Single Deployment Unit - Simple Design ❌ Cons - Independence - Autonomy

Slide 27

Slide 27 text

Architecture: 2022 ~ Customer App Customer gRPC Partner App Partner gRPC API Gateway

Slide 28

Slide 28 text

Architecture: 2022 ~ Commerce gRPC API Gateway Social GraphQL Customer GraphQL Federation (Apollo Router) Commerce GraphQL Social gRPC Platfrom Business

Slide 29

Slide 29 text

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