Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
liaosunny123 authored Aug 21, 2023
2 parents b06615d + a10a533 commit 8eff7fc
Show file tree
Hide file tree
Showing 31 changed files with 1,526 additions and 109 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Code Scan
on:
workflow_dispatch:
pull_request:
branches: [ "dev" ]

jobs:
qodana:
runs-on: ubuntu-latest
environment: Analysis
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
with:
pr-mode: false
args: --apply-fixes
push-fixes: pull-request
upload-result: true
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ RUN apk update --no-cache \
&& go mod download \
&& bash ./scripts/build-all.sh

FROM alpine as prod
FROM docker.io/epicmo/gugotik-basic:1.0 as prod

ENV TZ Asia/Shanghai

WORKDIR /work

RUN apk update --no-cache \
&& apk upgrade \
&& apk add yasm \
&& apk add ffmpeg \
&& rm -rf /var/cache/apk/*
&& apk upgrade

COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
COPY --from=builder /build/output .
7 changes: 7 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine

RUN apk update --no-cache \
&& apk upgrade \
&& apk add yasm \
&& apk add ffmpeg \
&& rm -rf /var/cache/apk/*
51 changes: 51 additions & 0 deletions docs/README-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# GuGoTik
GuGoTik是 第六届字节跳动青训营后端进阶 实战项目,题目为编写一个小型的抖音后端。
# 贡献者
项目开发者:这是一群来自五湖四海的 Contributors,来自于 WHU,HNU,NJUPT。
- [EpicMo](https://github.com/liaosunny123)
- [Maples](https://github.com/Maple-pro)
- [Attacks](https://github.com/Attack825)
- [amazing-compass](https://github.com/amazing-compass)
- [XFFFCCCC](https://github.com/XFFFCCCC)

特别感谢:
- [Eric](https://github.com/ExerciseBook)
- [Huang Yongliang](https://github.com/956237586)
- [nicognaW](https://github.com/nicognaW)

以及有事而无法参与项目的小伙伴:
- [Chuanwise](https://github.com/Chuanwise)

# 外部服务依赖
- Redis (Cluster)
- PostgreSQL
- Consul
- OpenTelemetry Collector
- FFMpeg
- Go

项目推荐使用以下可观测性基础设施:
- Jaeger
- Victoria Metrics
- Grafana

Profile 性能分析:
- Pyroscope

# 自部署流程
由 梦想珈 RyzeBot 提供自动推送至K8S集群构建流程。
PR 至 Dev 分支,经过基于 Action 的 UnitTest + Code Analysis + Lint + BuildCheck 后,可合并至 Master 分支。
Master 分支会自动触发 CD,构建镜像并推送,由 RyzeBot 完成向 K8S 的推送,自动部署。

# 配置
GuGoTik可以自动捕获环境变量,也可以以 .env 文件的方式手动提供,覆盖顺序为:
.env > 环境变量 > DefaultEnv > EmptyEnv(即默认提供空值,由GuGoTik提供运行时特判)

# 构建
## 基于 Standalone
运行 scripts 文件夹下 build-all 脚本,然后运行 run-all 脚本即可,请选择自己平台支持的脚本。
## 基于 Docker
```bash
docker pull epicmo/gugotik:latest
```
通过交互式终端进入容器后自行运行 GateWay 文件夹下和 Services 文件夹下程序
16 changes: 16 additions & 0 deletions manifest-dev/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
namespace: gugotik-service-bundle
data:
DREAM_APP_NAME: "gugotik-service-bundle"
DREAM_UNIT_NAME: "gugotik-service-bundle"
DREAM_APP_VERSION: "${CI_COMMIT_ID}"
DREAM_APP_ROOT: "/data/apps/gugotik-service-bundle"
DREAM_CFG_ACCESS_KEY: ''
DREAM_ENV: "TESTING"
DREAM_REGION_NAME: "endymx"
DREAM_SEC_APP_TOKEN: ''
DREAM_SERVICE_DISCOVERY_URI: 'consul://consul-server.consul.svc.cluster.local:8500'
DREAM_IMAGE_TAG: "${IMAGE_TAG}"
46 changes: 46 additions & 0 deletions manifest-dev/deployment-auth-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
sidecar.jaegertracing.io/inject: 'true'
labels:
app: gugotik-auth-service
name: gugotik-auth-service
namespace: gugotik-service-bundle
spec:
selector:
matchLabels:
name: gugotik-auth-service
template:
metadata:
labels:
app: gugotik-auth-service
branch: master
version: ${BUILD_NUMBER}-${CI_COMMIT_ID}
name: gugotik-auth-service
dream-app: gugotik-auth-service
dream-unit: gugotik-auth-service
spec:
imagePullSecrets:
- name: reg-cred
containers:
- image: ${IMAGE}
imagePullPolicy: IfNotPresent
name: gugotik-auth-service
command:
- ./services/AuthService
envFrom:
- configMapRef:
name: env-config
ports:
- name: grpc-37001
containerPort: 37001
protocol: TCP
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 8Mi
terminationGracePeriodSeconds: 30
4 changes: 4 additions & 0 deletions src/constant/config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ const PublishRpcServerPort = ":37005"
const FavoriteRpcServerName = "GuGoTik-FavoriteService"
const FavoriteRpcServerPort = ":37006"

const MessageRpcServerName = "GuGoTik-MessageService"
const MessageRpcServerPort = ":37007"

const RelationRpcServerName = "GuGoTik-RelationService"
const RelationRpcServerPort = ":37008"


const VideoPicker = "GuGoTik-VideoPicker"
22 changes: 15 additions & 7 deletions src/constant/strings/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@ const (
ActorIDNotMatchError = "用户不匹配"
UnableToDeleteCommentErrorCode = 50008
UnableToDeleteCommentError = "无法删除视频评论"
UnableToFollowErrorCode = 50009
UnableToAddMessageErrorCode = 50009
UnableToAddMessageRrror = "发送消息出错"
UnableToQueryMessageErrorCode = 50010
UnableToQueryMessageError = "查消息出错"
PublishServiceInnerErrorCode = 50011
PublishServiceInnerError = "发布服务出现内部错误,请稍后重试!"
UnableToFollowErrorCode = 50012
UnableToFollowError = "关注该用户失败"
UnableToUnFollowErrorCode = 50010
UnableToUnFollowErrorCode = 50013
UnableToUnFollowError = "取消关注失败"
UnableToGetFollowListErrorCode = 50011
UnableToGetFollowListErrorCode = 50014
UnableToGetFollowListError = "无法查询到关注列表"
UnableToGetFollowerListErrorCode = 50012
UnableToGetFollowerListErrorCode = 50015
UnableToGetFollowerListError = "无法查询到粉丝列表"
UnableToRelateYourselfErrorCode = 50013
UnableToRelateYourselfErrorCode = 50016
UnableToRelateYourselfError = "无法关注自己"
RelationNotFoundErrorCode = 50014
RelationNotFoundErrorCode = 50017
RelationNotFoundError = "未关注该用户"
StringToIntErrorCode = 50014
StringToIntErrorCode = 50018
StringToIntError = "字符串转数字失败"
)

Expand All @@ -56,4 +62,6 @@ const (
ActionCommentTypeInvalid = "不合法的评论类型"
ActionCommentLimitedCode = 10006
ActionCommentLimited = "评论频繁,请稍后再试!"
InvalidContentTypeCode = 10007
InvalidContentType = "不合法的内容类型"
)
5 changes: 4 additions & 1 deletion src/constant/strings/service.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package strings

const (
VideoPicker = "video_picker"
VideoExchange = "video_exchange"

VideoPicker = "video_picker"
VideoSummary = "video_summary"
)
25 changes: 25 additions & 0 deletions src/models/message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package models

import (
"GuGoTik/src/storage/database"

"gorm.io/gorm"
)

type Message struct {
ID uint32 `gorm:"not null;primarykey;autoIncrement"`
ToUserId uint32 `gorm:"not null" `
FromUserId uint32 `gorm:"not null"`
ConversationId string `gorm:"not null" index:"conversationid"`
Content string `gorm:"not null"`

// Create_time time.Time `gorm:"not null"`
//Updatetime deleteTime
gorm.Model
}

func init() {
if err := database.Client.AutoMigrate(&Message{}); err != nil {
panic(err)
}
}
5 changes: 3 additions & 2 deletions src/models/rawvideo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package models

type RawVideo struct {
ActorId uint32
VideoId uint32
Title string
FilePath string
CoverPath string
FileName string
CoverName string
}
12 changes: 8 additions & 4 deletions src/models/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import (

// Video 视频表
type Video struct {
ID uint32 `gorm:"not null;index:video;primarykey;autoIncrement"`
Title string `json:"title" gorm:"not null;"`
FileName string `json:"play_name" gorm:"not null;"`
CoverName string `json:"cover_name" gorm:"not null;"`
ID uint32 `gorm:"not null;primarykey;autoIncrement"`
Title string `json:"title" gorm:"not null;"`
FileName string `json:"play_name" gorm:"not null;"`
CoverName string `json:"cover_name" gorm:"not null;"`
AudioFileName string
Transcript string
Summary string
Keywords string // e.g., "keywords1 | keywords2 | keywords3"
gorm.Model
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (a AuthServiceImpl) Register(ctx context.Context, request *auth.RegisterReq
"username": request.Username,
}).Infof("User register success!")

resp.UserId = uint32(user.ID)
resp.UserId = user.ID
resp.StatusCode = strings.ServiceOKCode
resp.StatusMsg = strings.ServiceOK
return
Expand Down
1 change: 1 addition & 0 deletions src/services/comment/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (c CommentServiceImpl) ListComment(ctx context.Context, request *comment.Li
userMap[pComment.UserId] = &user.User{}
}
getUserInfoError := false

wg := sync.WaitGroup{}
wg.Add(len(userMap))
for userId := range userMap {
Expand Down
Loading

0 comments on commit 8eff7fc

Please sign in to comment.