GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: move timeline to micro service (#273) · gitLibs/server@c160d6a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitmodules
  • .golangci.yaml
  • Taskfile.yaml
  • buf.gen.yaml
  • buf.work.yaml
  • cmd/gen/gorm
    • main.go
  • config
    • config.go
  • ctrl
    • update_subject_collection.go
  • dal/query
    • gen.go
  • etc
    • mock.task.yaml
  • generated/proto/go/api/v1
    • timeline.pb.go
    • timeline_grpc.pb.go
  • go.mod
  • go.sum
  • internal
    • mocks
      • CharacterRepo.go
      • PrivateMessageRepo.go
      • SessionRepo.go
      • TimeLineRepo.go
      • UserRepo.go
    • model
      • timeline.go
      • type.go
    • pkg
      • test
        • web.go
      • tools
        • go.mod
        • go.sum
        • tools.go
      • util
        • copy.go
        • copy_internal_test.go
        • copy_test.go
    • timeline
      • domain.go
      • grpc.go
      • image
        • image.go
        • subject.go
      • memo
        • blog.go
        • convertor.go
        • doujin.go
        • group.go
        • index.go
        • mono.go
        • progress.go
        • relation.go
        • sayedit.go
        • subject.go
        • wiki.go
      • mysql_repo.go
      • mysql_repository.go
      • mysql_repository_test.go
  • proto
  • readme.md
  • web/handler/user
    • patch_subject_collection_test.go

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitmodules‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "pkg/wiki/testdata/wiki-syntax-spec"]
22
path = pkg/wiki/testdata/wiki-syntax-spec
33
url = https://github.com/bangumi/wiki-syntax-spec.git
4+
[submodule "proto"]
5+
path = proto
6+
url = [email protected]:bangumi/proto.git
Collapse file

‎.golangci.yaml‎

Copy file name to clipboardExpand all lines: .golangci.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ linters-settings:
174174

175175
importas:
176176
no-unaliased: false
177-
no-extra-aliases: true
177+
no-extra-aliases: false
178178
alias:
179179
- pkg: "log"
180180
alias: stdLog
Collapse file

‎Taskfile.yaml‎

Copy file name to clipboardExpand all lines: Taskfile.yaml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ tasks:
1111
cmds:
1212
- task --list
1313

14+
install:
15+
cmds:
16+
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
17+
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
18+
- go install github.com/vektra/mockery/v2@latest
19+
- echo "install buf by yourself https://docs.buf.build/installation"
20+
1421
build:
1522
desc: Build Web Server Binary
1623
sources:
@@ -78,6 +85,7 @@ tasks:
7885
gen:
7986
desc: Generate all generated GO files
8087
cmds:
88+
- cmd: buf generate
8189
- task: gorm
8290
- task: mock
8391
- task: dal:comment
Collapse file

‎buf.gen.yaml‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: v1
2+
3+
plugins:
4+
- plugin: go
5+
out: generated/proto/go
6+
opt: paths=source_relative
7+
- plugin: go-grpc
8+
out: generated/proto/go
9+
opt: paths=source_relative
Collapse file

‎buf.work.yaml‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: v1
2+
directories:
3+
- proto
Collapse file

‎cmd/gen/gorm/main.go‎

Copy file name to clipboardExpand all lines: cmd/gen/gorm/main.go
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ var characterIDTypeString = "model.CharacterID" // reflect.TypeOf(new(model.Char
4343
var episodeIDTypeString = "model.EpisodeID" // reflect.TypeOf(new(model.EpisodeID)).Elem().Name()
4444
var subjectIDTypeString = "model.SubjectID" // reflect.TypeOf(new(model.SubjectID)).Elem().Name()
4545
var groupIDTypeString = "model." + reflect.TypeOf(new(model.GroupID)).Elem().Name()
46-
var timelineIDTypeString = "model." + reflect.TypeOf(new(model.TimeLineID)).Elem().Name()
47-
var timelineCatTypeString = reflect.TypeOf(new(model.TimeLineCat)).Elem().Name()
4846
var subjectTypeIDTypeString = reflect.TypeOf(new(model.SubjectType)).Elem().Name()
4947
var episodeTypeTypeString = reflect.TypeOf(new(episode.Type)).Elem().Name()
5048
var notificationIDTypeString = "model." + reflect.TypeOf(new(model.NotificationID)).Elem().Name()
@@ -181,15 +179,6 @@ func main() {
181179

182180
g.ApplyBasic(oauthApp)
183181

184-
g.ApplyBasic(g.GenerateModelAs("chii_timeline", "TimeLine",
185-
gen.FieldTrimPrefix("tml_"),
186-
gen.FieldType("tml_id", timelineIDTypeString),
187-
gen.FieldType("tml_uid", userIDTypeString),
188-
gen.FieldType("tml_cat", timelineCatTypeString),
189-
gen.FieldType("tml_img", "[]byte"),
190-
gen.FieldType("tml_memo", "[]byte"),
191-
))
192-
193182
g.ApplyBasic(g.GenerateModelAs("chii_oauth_access_tokens", "AccessToken",
194183
gen.FieldType("type", "uint8"),
195184
gen.FieldType("id", "uint32"),
Collapse file

‎config/config.go‎

Copy file name to clipboardExpand all lines: config/config.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type AppConfig struct {
5757
DisableWords string `yaml:"disable_words"`
5858
BannedDomain string `yaml:"banned_domain"`
5959

60+
MicroServiceTimelineAddr string `yaml:"ms_timeline_addr" env:"MS_TIMELINE_ADDR"`
61+
6062
AppType string
6163
}
6264

Collapse file

‎ctrl/update_subject_collection.go‎

Copy file name to clipboardExpand all lines: ctrl/update_subject_collection.go
+5-22Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,7 @@ func (ctl Ctrl) UpdateCollection(
8080
privacy = null.New(model.CollectPrivacyBan)
8181
}
8282

83-
txErr := ctl.tx.Transaction(func(tx *query.Query) error {
84-
return ctl.updateSubjectCollection(ctx, tx, u, subjectID, original, req, privacy)
85-
})
86-
87-
return txErr
88-
}
89-
90-
// should run in tx.
91-
func (ctl Ctrl) updateSubjectCollection(
92-
ctx context.Context,
93-
tx *query.Query,
94-
u auth.Auth,
95-
subjectID model.SubjectID,
96-
originalCollection model.UserSubjectCollection,
97-
req UpdateCollectionRequest,
98-
privacy null.Null[model.CollectPrivacy],
99-
) error {
100-
err := ctl.collection.WithQuery(tx).UpdateSubjectCollection(ctx, u.ID, subjectID, collection.Update{
83+
err = ctl.collection.UpdateSubjectCollection(ctx, u.ID, subjectID, collection.Update{
10184
IP: req.IP,
10285
Comment: req.Comment,
10386
Tags: req.Tags,
@@ -107,18 +90,18 @@ func (ctl Ctrl) updateSubjectCollection(
10790
Rate: req.Rate,
10891
Privacy: privacy,
10992
}, time.Now())
93+
11094
if err != nil {
111-
ctl.log.Error("failed to update user collection info", zap.Error(err))
11295
return errgo.Wrap(err, "collectionRepo.UpdateSubjectCollection")
11396
}
11497

115-
if req.Type.Set && (req.Type.Value != originalCollection.Type) {
98+
if req.Type.Set && (req.Type.Value != original.Type) {
11699
sj, err := ctl.GetSubject(ctx, u, subjectID)
117100
if err != nil {
118101
return err
119102
}
120-
err = ctl.timeline.WithQuery(tx).
121-
ChangeSubjectCollection(ctx, u, sj, req.Type.Default(0), req.Comment.Value, req.Rate.Value)
103+
// TODO handle same type in timeline srv
104+
err = ctl.timeline.ChangeSubjectCollection(ctx, u, sj, req.Type.Default(0), req.Comment.Value, req.Rate.Value)
122105
if err != nil {
123106
ctl.log.Error("failed to create associated timeline", zap.Error(err))
124107
return errgo.Wrap(err, "timelineRepo.Create")
Collapse file

‎dal/query/gen.go‎

Copy file name to clipboardExpand all lines: dal/query/gen.go
-6Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎etc/mock.task.yaml‎

Copy file name to clipboardExpand all lines: etc/mock.task.yaml
+1-13Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
version: "3"
22

33
tasks:
4-
mockery:
5-
generates:
6-
- ./.bin/mockery.exe
7-
sources:
8-
- ./internal/pkg/tools/go.mod
9-
cmds:
10-
- cd ./internal/pkg/tools; go build -o ../../../.bin/mockery.exe github.com/vektra/mockery/v2
11-
run: once
12-
134
all:
14-
- task: mockery
155
- task: gen
166

177
gen:
@@ -40,10 +30,8 @@ tasks:
4030
- task: NotificationRepo
4131

4232
base-mock:
43-
deps:
44-
- mockery
4533
cmds:
46-
- cmd: ./.bin/mockery.exe --dir {{.SRC_DIR}} --filename '{{.MOCK_STRUCT|default .INTERFACE}}.go' --name '{{.INTERFACE | default "Manager"}}' --structname {{.MOCK_STRUCT|default .INTERFACE}} --output ./internal/mocks --with-expecter
34+
- cmd: mockery --dir {{.SRC_DIR}} --filename '{{.MOCK_STRUCT|default .INTERFACE}}.go' --name '{{.INTERFACE | default "Manager"}}' --structname {{.MOCK_STRUCT|default .INTERFACE}} --output ./internal/mocks --with-expecter
4735

4836
session-repo:
4937
sources:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.