Git Product home page Git Product logo

doutok's Introduction

👋 Hi, there's @TremblingV5

Contribution Stats

doutok's People

Contributors

abigailjixiangyuyu avatar baize1998 avatar cilangzzz avatar isjulia avatar issuemel avatar mr1q avatar newbieking avatar nw1ll avatar s145176 avatar tremblingv5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

doutok's Issues

[BUG] 关注关系导致的数量增长需要校验

复现方式

  1. 使用Postman调用relation/action使用户1关注用户2
  2. 记录此时用户1的关注数和用户2的粉丝数
  3. 重复步骤1
  4. 与步骤2记录的关注数和粉丝数进行对比(可以发现依然存在增长)

期望效果

上述复现方式中执行步骤4后,对比的结果应该是没有变化的,在执行步骤3时用户1已经关注了用户2,此时对关注数和粉丝数都不应该新增。

所以应该在进行已有的relation action时,不修改相关的计数变量

可能导致该问题的场景

  • 客户端Bug导致重复调用
  • 网络问题,用户猛点“关注”按钮多次,客户端发送连续多个的关注请求(之前出现过这类问题)

Add ELK Support for DouTok

What

Add ELK support for DouTok.

ELK(ES Logstash Kibana) is a normal log solution. Now DouTok will write log to files, it not easy to read and analysis logs. In enterprises developments or in large projects development, a log solution is important. We can read logs quickly by using ELK and so some other jobs by using these data.

Details

  1. Not only ELK, comment here or achieve if you have some other better solution.
  2. Create a single .yml file in ./env to use docker-compose to start related environment.
  3. Clarify the configurations in code and a code style without intrusion.

UI & Client Plan

Now we only can use a .apk file as client to request DouTok. So we plan to build a frontend app for DouTok. For simple implementation, we may crate a React app as the frontend. Support mobile is not an urgent goal. The directory ./ui used to store frontend code.

Obviously, there're some directly tasks for achieve this frontend app:

  • Building an app framework. We hope we can use some new technology.

Fix golangci-lint errors

What

Fix golangci-lint errors.

Details

golangci-lint is a normal linter for Golang. Now DouTok have many errors which we can found them by using golangci-lint run. Actually, these errors will not affect running DouTok. But these errors are not elegant enough, also may cause unnecessary bugs.

We suggest that open a new issue to tell everyone what you will do if you want to contribute for this issue. This will avoid different contributor do the same job.

一个小错误

What happened?

DouTok/applications/publish/rpc/user.go文件中的第19行,

func InitUserRpc() {
	config := dtviper.ConfigInit("DOUTOK_USER", "user")

	c, err := userservice.NewClient(
		config.Viper.GetString("Server.Name"),
		initHelper.InitRPCClientArgs(*config)...,😊😊这里的config多解引用了一次,
	)

	if err != nil {
		panic(err)
	}

	userClient = c
}

How to reproduce?

dtviper.ConfigInit 返回*dtviper.Config类型,所以不用再解引用了

Expected

Screenshots

Environment

How to start the first unit Testing

Question

个人想参与到DouTok的开发中。在看过“DouTok从0到1小帮手”后,想从编写单元测试开始。但我不知道怎么开始,请问能提供些学习材料和建议吗?(基本没有项目相关经验)

想问一下目前doutok的kafka部分是有哪些设计?

消息队列我可能确实不太熟,学习了一下必要知识就直接来看代码了。
我感觉从代码反推设计目前对我来说太难了
目前直接一点的问题是,我能找到 ConsumerGroup.Consume 在那里初始化,但是没法了解到具体是怎样一个消费流程
换句话说,我想知道这个项目中,消息队列都做了哪些事情

DouTok从0到1小帮手

首先,非常欢迎大家能够参与DouTok的项目维护。也非常感谢大家能够花时间在DouTok上,无论是简单浏览,还是提出意见,或是直接贡献参与项目。

很多同学表示难以下手,对此我持反对意见。

开源贡献并不代表只有提交业务代码才叫做开源贡献。开源贡献的途径有很多,例如:

  • 发表Issue
  • 开启Discussion
  • 完善项目文档
  • 添加单元测试
  • 提交业务代码

发表Issue和开启Discussion

这两样工作是很容易被人轻视的,但是这并不代表他们不重要。DouTok提供了4种Issue模板,包括报Bug、提需求、讨论、和“Anything”。各种各样的Issue和Discussion是开源贡献的基础,DouTok非常欢迎大家能够提Issue或者开启Discussion,请不要害怕发表的观点“太简单”或是“有错误”。请所有人大胆发言

如果您认为DouTok哪里做的不好,请提Issue。

如果您不明白DouTok为什么这么做,请提Issue。

如果您有任何疑问,请提Issue。

如果您想参与DouTok但不知道该做什么,请提Issue。可以在Issue中简单介绍一下自己,描述一下自己希望能做什么样的工作,DouTok会尽全力帮您寻找一个适合的功能点来提供给您。

完善项目文档

在本Issue刚创建的时刻,DouTok的文档站刚刚创建成功,可以通过这个链接访问:https://doutok.zhengfei.xin

项目文档也是一个软件产品重要的一部分。在文档网站中,您可以寻找任何可以添加文档的部分,编写文档,然后提交PR,最终合并。哪怕寥寥几行内容,也会是文档的组成部分,至少可以是开启提交PR之路的一个起点。

添加单元测试

DouTok虽然是一个看起来还很稚嫩的项目,但也依赖了一堆环境,也有了一定量的代码。有的同学可能不太能够顺利的把整个项目跑起来,又或是不太能够把相关的环境部署下来,这些都不妨碍去编写一些单元测试。如果一个软件产品想要尽可能的健康,单元测试是整个目标的第一步。只要您能安装一个Golang环境,那么就能直接编写单元测试的代码。编写单元测试,即能够逐渐掌握项目内容的来龙去脉,又能够为整个项目的稳定运行添砖加瓦。DouTok项目的Github Actions中配置了在每次提交PR时都会运行全部的单元测试,也就是说,您提交的所有单元测试在任何人提交PR时都会运行至少一遍,您的单元测试在为DouTok保驾护航。

提交业务代码

提交业务代码是最直接的提升DouTok的途径,当您选择提交代码时,我想这里也不需要过多的介绍。想要提交业务代码,请首先确认要做什么。

如果不知道想要做什么,可以在DouTok的Issue列表中浏览一下,那里会有一些明确的需要帮助的Issue可供完成。

如果想要做某些事情,但是Issue中又没有,烦请添加一条对应的Issue用以描述将要做的事情,这么做可以防止其他贡献者在不知情的情况下做了一样的工作。

关于服务数量和划分、配置方式、DouTok未来发展方向等问题讨论

最近和 @BaiZe1998 商量后,决定把主要的业务代码回退到当时青训营结束时的一个版本,这么做的原因有:

  • 现有的服务划分很冗余,虽然一定程度上解决了循环调用的问题,但是造成了极大的冗余,并且很难看
  • 从现有版本直接进行服务合并耗时比较长,希望能尽快结束合并的工作,然后开始迭代(前段时间我本人实习工作、搞毕业论文等时间太紧张,后续2~3个月我分配给DouTok的时间会比较多)

和这段时间有贡献的几位同学说声抱歉。

我尽量保留了大家贡献的代码,例如配置等,后续我会尽可能把大家贡献的代码给用起来。

下一步的计划

关于服务划分

DouTok最初有这些模块:api, comment, favorite, publish, feed, user, message等,由于接口定义不够清晰,导致在一些情况下会出现循环调用(即使并不会发生无限循环),为了解决这个看起来不够“优雅”的问题,我选择了一条错误的、费事的道路,给微服务像MVC架构那样去分层。这样做虽然基本解决了循环调用,但是服务数量也特别多,在实际业务场景中,随着业务的扩张,服务的数量也将快速增长,显然这样是不合理的。

后续打算沿用原有的模块划分,可能会对一些模块进行合并,例如我个人感觉publish, feed模块可以合并为"video"模块,具体的feed服务可以在未来去搞一个建议的推荐服务。

在原有模块划分的基础上,对除api模块外的每个模块定义2套服务。一套面向网关,一套面向各个微服务。面向网关的服务将返回具体的字段信息,而面向微服务的服务将只返回服务管辖范围内的数据的id,具体的数据内容则调用对应服务去查询。

关于配置

后续打算基于viper和etcd去做配置中心,通过一个环境变量来确定从文件读配置还是从配置中心读配置。在开发或是部署情况下分别使用对应的方式来读取配置。

这段时间我工作工程中也看到了关于配置的一些封装,我会尝试进行实现。

@BaiZe1998 @AbigailJixiangyuyu @issueMel @newbieking @cilangzzz

希望各位同学能分享下自己的看法,不仅限于上述2个问题,关于DouTok未来架构怎么发展,去做什么样的功能,都欢迎大家能提意见、发表想法

Use hertz-swagger to enhance api documents

What

Use hertz-swagger to enhance api documents

Details

To facilitate front-end development, we may need an api documents. As we know, swagger is a good way to do this job. We can read the documents for hertz-swagger.

https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/middleware/swagger/

We need to add some comments to tell us what the api need and what to response. Also, we may add some commands by using Makefile to let us to use make .... to generate the documents of api.

Using MongoDB instead of HBase

What

Now DouTok use HBase as a storage to save some data, such as message, video etc. For using row key of HBase to improve data loading, DouTok is using HBase.

Now we hope we can use MongoDB instead of HBase. Because:

  1. HBase is a component which is not too easy to deploy
  2. HBase have some problem on Mac 14 M1

MongoDB is more easy so we may select it.

Details

  • Create some interfaces as the abstract methods related with MongoDB.
  • Add implements using MongoDB.
  • Do not remove methods HBase, we can keep them and use config variable to select one when we running DouTok. We can use them to do some pressure testing and compare them.

Refactor Plan

There're some plan for refactor DouTok. If you have some advices, please comment here.

Also, welcome to select one or more entries to do something and that's DouTok's pleasure. If you want to make some contributions to DouTok, we suggest open another issue which used to tell everyone what you want to do and assign it to yourself. In the way, we can avoid different people doing the same job.

The following is something what we want to do. Absolutely, anything that does not appear below is acceptable.

Run & Build & Deploy

  • Explore how to run applications easily. Now we have many modules, we only can run them by using go run ./applications/xxx/. We may use a better way to do these. See more on: #112

CI/CD

  • Add golangci-lint to lint code by using github actions
  • Run go test when open a PR
  • Add a flow to obtain unit test coverage

Code Layout

Now the code of DouTok still not elegant enough. Code layout is a big problem. There many places in this repo is not OOP (although golang is not a 100% OOP language). We suggest that we can improve the code layout of this repo. applications/commentDomain is an example.

Some package may need refactor:

  • applications/feed
  • applications/message
  • applications/messageDomain
  • applications/publish
  • applications/relationDomain @xwxb

Unit Test

Unfortunately, DouTok is poor on unit test. So any contributions for any package are welcome.

关于int64精度丢失的问题

我注意到一些接口返回了int64类型的数据,如user_id。
但由于前端js是使用双精度浮点型接收该类数据,会导致数据失真,需要进行处理,将int64转换为string类型再返回。我有一些方案,但不知道哪种方案更好。

  1. 使用中间件拦截返回数据进行重写
  2. handler.SendResponse 内部处理结构体
  3. 修改hertz的Marshal函数

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.