Highly concurrent mall system built on go-zero

  • By dawn_zhou
  • Last update: Jan 8, 2023
  • Comments: 3

lebron

Highly concurrent mall system built on go-zero

Architecture

A busy sum, when there is time to make up for it

Series of Courses

go-zero 微服务实战系列(一、开篇)

go-zero 微服务实战系列(二、服务拆分)

go-zero微服务实战系列(三、API定义和表结构设计)

go-zero微服务实战系列(四、CRUD热身)

go-zero微服务实战系列(五、缓存代码怎么写)

go-zero微服务实战系列(六、缓存一致性保证)

go-zero微服务实战系列(七、请求量这么高该如何优化)

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

go-zero微服务实战系列(九、极致优化秒杀性能)

Basic Environment

Name Description Link
Go-Zero Web & Rpc Go Frame https://go-zero.dev/cn/
Mysql DB https://www.mysql.com/
Redis Cache https://redis.io/
Docker Code Runtime Environment https://www.docker.com/
MQ

Code Components

Name Description Link
sqlx db table crud
copier copy value from struct to struct and more github.com/jinzhu/copier

Business Function

img.png

Server Port

API

server name port
api bff 8001

RPC

server name port
user rpc 9001
product rpc 9002
order rpc 9003

Download

lebron.zip

Comments(3)

  • 1

    addCacheProductList的Context传递

    https://github.com/zhoushuguang/lebron/blob/13ddeceee4f58459711f2f45302990ec5149913a/apps/product/rpc/internal/logic/productlistlogic.go#L124 请问此处传l.ctx更合适还是context.Background()更合适呢

  • 2

    orderitem表结构需要重新更新下

    https://github.com/zhoushuguang/lebron/blob/faf0719a58af6667ac1d413cb2096b69b768a1c6/sql/mall.sql#L107 1.字段按照其他表统一为没有下划线格式 2.id增加AUTO_INCREMENT属性

    CREATE TABLE orderitem ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单子表id', orderid varchar(64) NOT NULL DEFAULT '' COMMENT '订单id', userid bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户id', proid bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品id', proname varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称', proimage varchar(500) NOT NULL DEFAULT '' COMMENT '商品图片地址', currentunitprice decimal(20, 2) NOT NULL DEFAULT 0 COMMENT '生成订单时的商品单价,单位是元,保留两位小数', quantity int(10) NOT NULL DEFAULT 0 COMMENT '商品数量', totalprice decimal(20, 2) NOT NULL DEFAULT 0 COMMENT '商品总价,单位是元,保留两位小数', create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (id), KEY ix_orderid (orderid), KEY ix_userid (userid), KEY ix_proid (proid) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='订单明细表';

  • 3

    ProductList 的请求参数为什么会有ProductId