feature/fanout #3

Merged
daniel.w merged 11 commits from feature/fanout into main 2024-09-03 11:45:06 +00:00
8 changed files with 130 additions and 5 deletions
Showing only changes of commit c9a0926495 - Show all commits

View File

@ -1,5 +1,2 @@
use digimon_tweeting;
db.comment.createIndex({ "post_id": 1,"createAt":1});
// TODO 看是否有要刪除過多的索引,要在測試一下

View File

@ -182,3 +182,34 @@ service CommentService
// UpdateComment
rpc UpdateComment(UpdateCommentReq) returns (OKResp);
}
// ========== TimeLineService () ==========
message GetTimelineReq
{
string uid = 1; // ID
int32 pageIndex = 2; //
int32 pageSize = 3; //
}
message GetTimelineResp
{
repeated PostDetailItem posts = 1; //
Pager page = 2; //
}
message AddPostToTimelineReq
{
string uid = 1; // key
repeated PostDetailItem posts = 2;
}
// TimelineService
service TimelineService
{
// AddPostToTimeline
// 1000 1000
//
rpc AddPostToTimeline(GetTimelineReq) returns (OKResp);
// GetTimeline
rpc GetTimeline(GetTimelineReq) returns (GetTimelineResp);
}

View File

@ -0,0 +1,31 @@
package timelineservicelogic
import (
"context"
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
"app-cloudep-tweeting-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type AddPostToTimelineLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewAddPostToTimelineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddPostToTimelineLogic {
return &AddPostToTimelineLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// AddPostToTimeline 加入貼文,只管一股腦全塞,這裡會自動判斷
func (l *AddPostToTimelineLogic) AddPostToTimeline(in *tweeting.GetTimelineReq) (*tweeting.OKResp, error) {
// todo: add your logic here and delete this line
return &tweeting.OKResp{}, nil
}

View File

@ -0,0 +1,31 @@
package timelineservicelogic
import (
"context"
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
"app-cloudep-tweeting-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetTimelineLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetTimelineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTimelineLogic {
return &GetTimelineLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetTimeline 取得這個人的動態時報
func (l *GetTimelineLogic) GetTimeline(in *tweeting.GetTimelineReq) (*tweeting.GetTimelineResp, error) {
// todo: add your logic here and delete this line
return &tweeting.GetTimelineResp{}, nil
}

View File

@ -7,7 +7,7 @@ import (
"context"
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
commentservicelogic "app-cloudep-tweeting-service/internal/logic/commentservice"
"app-cloudep-tweeting-service/internal/logic/commentservice"
"app-cloudep-tweeting-service/internal/svc"
)

View File

@ -7,7 +7,7 @@ import (
"context"
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
postservicelogic "app-cloudep-tweeting-service/internal/logic/postservice"
"app-cloudep-tweeting-service/internal/logic/postservice"
"app-cloudep-tweeting-service/internal/svc"
)

View File

@ -0,0 +1,35 @@
// Code generated by goctl. DO NOT EDIT.
// Source: tweeting.proto
package server
import (
"context"
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
"app-cloudep-tweeting-service/internal/logic/timelineservice"
"app-cloudep-tweeting-service/internal/svc"
)
type TimelineServiceServer struct {
svcCtx *svc.ServiceContext
tweeting.UnimplementedTimelineServiceServer
}
func NewTimelineServiceServer(svcCtx *svc.ServiceContext) *TimelineServiceServer {
return &TimelineServiceServer{
svcCtx: svcCtx,
}
}
// AddPostToTimeline 加入貼文,只管一股腦全塞,這裡會自動判斷
func (s *TimelineServiceServer) AddPostToTimeline(ctx context.Context, in *tweeting.GetTimelineReq) (*tweeting.OKResp, error) {
l := timelineservicelogic.NewAddPostToTimelineLogic(ctx, s.svcCtx)
return l.AddPostToTimeline(in)
}
// GetTimeline 取得這個人的動態時報
func (s *TimelineServiceServer) GetTimeline(ctx context.Context, in *tweeting.GetTimelineReq) (*tweeting.GetTimelineResp, error) {
l := timelineservicelogic.NewGetTimelineLogic(ctx, s.svcCtx)
return l.GetTimeline(in)
}