GeezerVison is showing github.com — refactor: move timeline to micro service (#273) · gitLibs/server@c160d6a
File treeExpand file treeCollapse file tree Open diff view settings generated/proto/go/api/v1
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | [submodule "pkg/wiki/testdata/wiki-syntax-spec"] | 2 | 2 | path = pkg/wiki/testdata/wiki-syntax-spec | 3 | 3 | url = https://github.com/bangumi/wiki-syntax-spec.git | | 4 | +[submodule "proto"] | | 5 | + path = proto | | 6 | + |
Collapse file Copy file name to clipboardExpand all lines: .golangci.yaml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -174,7 +174,7 @@ linters-settings: | 174 | 174 |
| 175 | 175 | importas: | 176 | 176 | no-unaliased: false | 177 | | - no-extra-aliases: true | | 177 | + no-extra-aliases: false | 178 | 178 | alias: | 179 | 179 | - pkg: "log" | 180 | 180 | alias: stdLog | |
Collapse file Copy file name to clipboardExpand all lines: Taskfile.yaml +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,13 @@ tasks: | 11 | 11 | cmds: | 12 | 12 | - task --list | 13 | 13 |
| | 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 | + | 14 | 21 | build: | 15 | 22 | desc: Build Web Server Binary | 16 | 23 | sources: | | 78 | 85 | gen: | 79 | 86 | desc: Generate all generated GO files | 80 | 87 | cmds: | | 88 | + - cmd: buf generate | 81 | 89 | - task: gorm | 82 | 90 | - task: mock | 83 | 91 | - task: dal:comment | |
Collapse file Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +version: v1 | | 2 | +directories: | | 3 | + - proto |
Collapse file Copy file name to clipboardExpand all lines: cmd/gen/gorm/main.go -11Lines changed: 0 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,8 +43,6 @@ var characterIDTypeString = "model.CharacterID" // reflect.TypeOf(new(model.Char | 43 | 43 | var episodeIDTypeString = "model.EpisodeID" // reflect.TypeOf(new(model.EpisodeID)).Elem().Name() | 44 | 44 | var subjectIDTypeString = "model.SubjectID" // reflect.TypeOf(new(model.SubjectID)).Elem().Name() | 45 | 45 | 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() | 48 | 46 | var subjectTypeIDTypeString = reflect.TypeOf(new(model.SubjectType)).Elem().Name() | 49 | 47 | var episodeTypeTypeString = reflect.TypeOf(new(episode.Type)).Elem().Name() | 50 | 48 | var notificationIDTypeString = "model." + reflect.TypeOf(new(model.NotificationID)).Elem().Name() | @@ -181,15 +179,6 @@ func main() { | 181 | 179 |
| 182 | 180 | g.ApplyBasic(oauthApp) | 183 | 181 |
| 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 | | - | 193 | 182 | g.ApplyBasic(g.GenerateModelAs("chii_oauth_access_tokens", "AccessToken", | 194 | 183 | gen.FieldType("type", "uint8"), | 195 | 184 | gen.FieldType("id", "uint32"), | |
Collapse file Copy file name to clipboardExpand all lines: config/config.go +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,6 +57,8 @@ type AppConfig struct { | 57 | 57 | DisableWords string `yaml:"disable_words"` | 58 | 58 | BannedDomain string `yaml:"banned_domain"` | 59 | 59 |
| | 60 | + MicroServiceTimelineAddr string `yaml:"ms_timeline_addr" env:"MS_TIMELINE_ADDR"` | | 61 | + | 60 | 62 | AppType string | 61 | 63 | } | 62 | 64 |
| |
Collapse file Copy file name to clipboardExpand all lines: ctrl/update_subject_collection.go +5-22Lines changed: 5 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,24 +80,7 @@ func (ctl Ctrl) UpdateCollection( | 80 | 80 | privacy = null.New(model.CollectPrivacyBan) | 81 | 81 | } | 82 | 82 |
| 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{ | 101 | 84 | IP: req.IP, | 102 | 85 | Comment: req.Comment, | 103 | 86 | Tags: req.Tags, | @@ -107,18 +90,18 @@ func (ctl Ctrl) updateSubjectCollection( | 107 | 90 | Rate: req.Rate, | 108 | 91 | Privacy: privacy, | 109 | 92 | }, time.Now()) | | 93 | + | 110 | 94 | if err != nil { | 111 | | - ctl.log.Error("failed to update user collection info", zap.Error(err)) | 112 | 95 | return errgo.Wrap(err, "collectionRepo.UpdateSubjectCollection") | 113 | 96 | } | 114 | 97 |
| 115 | | - if req.Type.Set && (req.Type.Value != originalCollection.Type) { | | 98 | + if req.Type.Set && (req.Type.Value != original.Type) { | 116 | 99 | sj, err := ctl.GetSubject(ctx, u, subjectID) | 117 | 100 | if err != nil { | 118 | 101 | return err | 119 | 102 | } | 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) | 122 | 105 | if err != nil { | 123 | 106 | ctl.log.Error("failed to create associated timeline", zap.Error(err)) | 124 | 107 | return errgo.Wrap(err, "timelineRepo.Create") | |
Collapse file Copy file name to clipboardExpand all lines: dal/query/gen.go -6Lines changed: 0 additions & 6 deletions Collapse file Copy file name to clipboardExpand all lines: etc/mock.task.yaml +1-13Lines changed: 1 addition & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | version: "3" | 2 | 2 |
| 3 | 3 | 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 | | - | 13 | 4 | all: | 14 | | - - task: mockery | 15 | 5 | - task: gen | 16 | 6 |
| 17 | 7 | gen: | @@ -40,10 +30,8 @@ tasks: | 40 | 30 | - task: NotificationRepo | 41 | 31 |
| 42 | 32 | base-mock: | 43 | | - deps: | 44 | | - - mockery | 45 | 33 | 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 | 47 | 35 |
| 48 | 36 | session-repo: | 49 | 37 | sources: | |
|