# Easy Note
## Introduction
Add a demo for `kitex` which implements a simple note service,the demo is divided into three main sections.
| Service Name | Usage | Framework | protocol | Path | IDL |
| --------------- | ------------ | ---------- | -------- | ---------------------- | ----------------------------------------- |
| demoapi | http interface | kitex/gin | http | bizdemo/easy_note/cmd/api | |
| demouser | user data management | kitex/gorm | protobuf | bizdemo/easy_note/cmd/user | bizdemo/easy_note/idl/user.proto |
| demonote | note data management | kitex/gorm | thrift | bizdemo/easy_note/cmd/note | bizdemo/easy_note/idl/note.thrift |
### call relations
```
http
┌────────────────────────┐
┌─────────────────────────┤ ├───────────────────────────────┐
│ │ demoapi │ │
│ ┌──────────────────► │◄──────────────────────┐ │
│ │ └───────────▲────────────┘ │ │
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
│ │ resolve │ │
│ │ │ │ │
req resp │ resp req
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
│ │ ┌──────────▼─────────┐ │ │
│ │ │ │ │ │
│ │ ┌───────────► Etcd ◄─────────────────┐ │ │
│ │ │ │ │ │ │ │
│ │ │ └────────────────────┘ │ │ │
│ │ │ │ │ │
│ │ register register │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
┌▼──────┴───────┴───┐ ┌──┴────────┴───────▼─┐
│ │───────────────── req ────────────────────►│ │
│ demonote │ │ demouser │
│ │◄──────────────── resp ────────────────────│ │
└───────────────────┘ └─────────────────────┘
thrift protobuf
```
### Use Basic Features
- Middleware、Rate Limiting、Request Retry、Timeout Control、Connection Multiplexing
- Tracing
- use jaeger to tracing
- Customized BoundHandler
- achieve CPU utilization rate customized bound handler
- Service Discovery and Register
- use [registry-etcd](https://github.com/kitex-contrib/registry-etcd) to discovery and register service
### catalog introduce
| catalog | introduce |
| ---------- | ---------------- |
| pkg/constants | constant |
| pkg/bound | customized bound handler |
| pkg/errno | customized error number |
| pkg/middleware | RPC middleware |
| pkg/tracer | init jaeger |
| dal | db operation |
| pack | data pack |
| service | business logic |
## Quick Start
### 1.Setup Basic Dependence
```shell
docker-compose up
```
### 2.Run Note RPC Server
```shell
cd cmd/note
sh build.sh
sh output/bootstrap.sh
```
### 3.Run User RPC Server
```shell
cd cmd/user
sh build.sh
sh output/bootstrap.sh
```
### 4.Run API Server
```shell
cd cmd/api
chmod +x run.sh
./run.sh
```
### 5.Jaeger
visit `http://127.0.0.1:16686/` on browser.
#### Snapshots
<img src="images/shot.png" width="2850" alt=""/>
## API requests
### Register
```shell
curl --location --request POST '127.0.0.1:8080/v1/user/register' \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"kinggo",
"password":"123456"
}'
```
#### response
```javascript
{
"code": 0,
"message": "Success",
"data": null
}
```
### Login
#### will return jwt token
```shell
curl --location --request POST '127.0.0.1:8080/v1/user/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"kinggo",
"password":"123456"
}'
```
#### response
```javascript
{
"code": 200,
"expire": "2022-01-19T01:56:46+08:00",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDI1Mjg2MDYsImlkIjoxLCJvcmlnX2lhdCI6MTY0MjUyNTAwNn0.k7Ah9G4Enap9YiDP_rKr5HSzF-fc3cIxwMZAGeOySqU"
}
```
### Create Note
```shell
curl --location --request POST '127.0.0.1:8080/v1/note' \
--header 'Authorization: Bearer $token' \
--header 'Content-Type: application/json' \
--data-raw '{
"title":"test title",
"content":"test content"
}'
```
#### response
```javascript
{
"code": 0,
"message": "Success",
"data": null
}
```
### Query Note
```shell
curl --location --request GET '127.0.0.1:8080/v1/note/query?offset=0&limit=20&search_keyword=test' \
--header 'Authorization: Bearer $token'
```
#### response
```javascript
{
"code": 0,
"message": "Success",
"data": {
"notes": [
{
"note_id": 1,
"user_id": 1,
"user_name": "kinggo",
"user_avatar": "test",
"title": "test title",
"content": "test content",
"create_time": 1642525063
}
],
"total": 1
}
}
```
### Update Note
```shell
curl --location --request PUT '127.0.0.1:8080/v1/note/$note_id' \
--header 'Authorization: Bearer $token' \
--header 'Content-Type: application/json' \
--data-raw '{
"title":"test",
"content":"test"
}'
```
#### response
```javascript
{
"code": 0,
"message": "Success",
"data": null
}
```
### Delete Note
```shell
curl --location --request DELETE '127.0.0.1:8080/v1/note/$note_id' \
--header 'Authorization: Bearer $token'
```
#### r
没有合适的资源?快使用搜索试试~ 我知道了~
字节跳动2022年青训营笔记.zip
共927个文件
png:657个
go:173个
md:27个
需积分: 5 1 下载量 5 浏览量
2024-05-01
11:27:03
上传
评论
收藏 131.81MB ZIP 举报
温馨提示
字节跳动2022年青训营笔记.zip
资源推荐
资源详情
资源评论
收起资源包目录
字节跳动2022年青训营笔记.zip (927个子文件)
963cc2ac9eb5405e8ab916606a1f7a03tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 35KB
412c9fc35e4c478e95deb585ddf21f75tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 34KB
e15113ef366d481fbd8b75fee43b6fd9tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 28KB
f893e75e31844c19bfbd820acd523efftplv-k3u1fbpfcp-zoom-in-crop-mark1304000-16524983365417.awebp 20KB
f893e75e31844c19bfbd820acd523efftplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 20KB
25a16f24fd4c48ed8915248b31bd0d6ftplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 18KB
c529157fd88a48bd88819533ca3b54a3tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 14KB
569c278f98a746d3ae97cd8ddff6a213tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 7KB
e3c4fd6622f24c6b95d2de18a7488f68tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 7KB
279daa762d0149fc856a937972442340tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 6KB
510bcba0f0d946f5a459be59c063e33etplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 6KB
089ec51585cd4d4aa11f294095ae6979tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 6KB
19e835280f594639bf88ce65655de69btplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 3KB
b46e3548bca6497991d4f271b066fc62tplv-k3u1fbpfcp-zoom-in-crop-mark1304000.awebp 3KB
.gitignore 3KB
.gitignore 274B
.gitignore 274B
.gitignore 54B
.gitignore 6B
note.go 133KB
k-note.go 100KB
user.pb.go 23KB
userservice.go 9KB
noteservice.go 6KB
main.go 5KB
main.go 4KB
handler.go 4KB
main.go 3KB
note.go 3KB
main.go 3KB
caiyun.go 3KB
client.go 3KB
main.go 3KB
main.go 3KB
handler.go 3KB
baidu.go 3KB
main.go 3KB
user.go 3KB
main.go 3KB
main.go 3KB
note.go 2KB
main.go 2KB
user.go 2KB
main.go 2KB
client.go 2KB
main.go 2KB
main.go 2KB
cpu.go 2KB
query_note.go 2KB
add_post.go 2KB
add_topic.go 2KB
main.go 2KB
sort.go 2KB
update_note.go 2KB
query_note.go 2KB
main.go 2KB
errno.go 2KB
mget_note.go 2KB
main.go 2KB
query_page_info.go 2KB
query_page_info.go 2KB
create_note.go 2KB
user.go 2KB
delete_note.go 2KB
check_user.go 2KB
create_user.go 2KB
note.go 2KB
db_init.go 1KB
constant_bak.go 1KB
main.go 1KB
register.go 1KB
main.go 1KB
main.go 1KB
db_init.go 1KB
common.go 1KB
main.go 1KB
client.go 1KB
mget_user.go 1KB
handler.go 1KB
create_note.go 1KB
resp.go 1KB
resp.go 1KB
init.go 1KB
init.go 1KB
server.go 1KB
update_note.go 1KB
user.go 1KB
delete_note.go 1KB
tracer.go 1KB
db_helper.go 1KB
main.go 988B
main.go 985B
main.go 984B
add_topic.go 972B
add_post.go 965B
slice_test.go 948B
main.go 943B
server.go 939B
main.go 876B
main.go 833B
共 927 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
JJJ69
- 粉丝: 6345
- 资源: 5918
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 旧版鲁大师绿色免安装精简
- SSM驾考管理系统程序源码52150
- 机器学习(图像识别):垃圾检测和分割的图像数据集
- SAC-Auto路径规划, Soft Actor-Critic算法, SAC-pytorch,激光雷达Lidar避障仿真模拟
- python基础之综合练习一-38.黑色星期五Friday the Thirteenth-13日.py
- 基于STM32F4进行图像处理,识别图像画面中较亮的三个光点,并且通过串口打印出三个光点的坐标
- python基础之综合练习一-37.贪婪的送礼者Greedy Gift Givers-这是你的,这是他的~.py
- python爱心代码高级粒子-36.分数线划定-这么直接ov0.py
- 安卓-报名助手.apk
- data_view.html
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功