Skip to content

Commit

Permalink
feat: remove mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Feb 12, 2024
1 parent 408176b commit 4cd88ab
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 189 deletions.
2 changes: 1 addition & 1 deletion app/mapper/cmd/mapper/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/mapper/pkg/service/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/miner/cmd/miner/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/miner/pkg/service/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/searcher/cmd/searcher/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/searcher/pkg/service/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions app/sephirah/cmd/sephirah/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions app/sephirah/internal/biz/bizangela/angela.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/tuihub/librarian/internal/lib/libmq"
"github.com/tuihub/librarian/internal/model"
"github.com/tuihub/librarian/internal/model/modelfeed"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"
porter "github.com/tuihub/protos/pkg/librarian/porter/v1"

"github.com/google/wire"
Expand All @@ -40,10 +39,10 @@ type Angela struct {
mq *libmq.MQ
}
type AngelaBase struct {
repo AngelaRepo
supv *supervisor.Supervisor
g bizgebura.GeburaRepo
mapper mapper.LibrarianMapperServiceClient
repo AngelaRepo
supv *supervisor.Supervisor
g bizgebura.GeburaRepo
// mapper mapper.LibrarianMapperServiceClient
searcher *client.Searcher
porter porter.LibrarianPorterServiceClient
}
Expand All @@ -63,15 +62,15 @@ func NewAngelaBase(
repo AngelaRepo,
supv *supervisor.Supervisor,
g bizgebura.GeburaRepo,
mClient mapper.LibrarianMapperServiceClient,
// mClient mapper.LibrarianMapperServiceClient,
pClient porter.LibrarianPorterServiceClient,
sClient *client.Searcher,
) (*AngelaBase, error) {
return &AngelaBase{
repo: repo,
supv: supv,
g: g,
mapper: mClient,
repo: repo,
supv: supv,
g: g,
//mapper: mClient,
porter: pClient,
searcher: sClient,
}, nil
Expand Down
7 changes: 3 additions & 4 deletions app/sephirah/internal/biz/bizbinah/binah.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (

"github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah"
"github.com/tuihub/librarian/internal/lib/libauth"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"
searcher "github.com/tuihub/protos/pkg/librarian/searcher/v1"
)

type Binah struct {
repo BinahRepo
callback *modelbinah.ControlBlock
auth *libauth.Auth
mapper mapper.LibrarianMapperServiceClient
// mapper mapper.LibrarianMapperServiceClient
searcher searcher.LibrarianSearcherServiceClient
}

Expand All @@ -37,14 +36,14 @@ func NewBinah(
repo BinahRepo,
callback *modelbinah.ControlBlock,
auth *libauth.Auth,
mClient mapper.LibrarianMapperServiceClient,
// mClient mapper.LibrarianMapperServiceClient,
sClient searcher.LibrarianSearcherServiceClient,
) *Binah {
return &Binah{
repo: repo,
callback: callback,
auth: auth,
mapper: mClient,
//mapper: mClient,
searcher: sClient,
}
}
Expand Down
17 changes: 8 additions & 9 deletions app/sephirah/internal/biz/bizgebura/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura"
"github.com/tuihub/librarian/internal/lib/libauth"
"github.com/tuihub/librarian/internal/model"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"
searcherpb "github.com/tuihub/protos/pkg/librarian/searcher/v1"
pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1"

Expand All @@ -30,14 +29,14 @@ func (g *Gebura) CreateApp(ctx context.Context, app *modelgebura.App) (*modelgeb
app.SourceAppID = strconv.FormatInt(int64(app.ID), 10)
app.SourceURL = ""
app.BoundInternal = app.ID
if _, err = g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{
VertexList: []*mapper.Vertex{{
Vid: int64(app.ID),
Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
}},
}); err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
// if _, err = g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{
// VertexList: []*mapper.Vertex{{
// Vid: int64(app.ID),
// Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
// }},
// }); err != nil {
// return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
//}
if err = g.repo.CreateApp(ctx, app); err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
Expand Down
22 changes: 11 additions & 11 deletions app/sephirah/internal/biz/bizgebura/app_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func (g *Gebura) CreateAppPackage(
a.ID = id
a.Source = modelgebura.AppPackageSourceManual
a.SourceID = 0
if _, err = g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{
VertexList: []*mapper.Vertex{{
Vid: int64(a.ID),
Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
}},
}); err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
// if _, err = g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{
// VertexList: []*mapper.Vertex{{
// Vid: int64(a.ID),
// Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
// }},
// }); err != nil {
// return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
//}
if err = g.repo.CreateAppPackage(ctx, claims.UserID, a); err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
Expand Down Expand Up @@ -145,9 +145,9 @@ func (r *reportAppPackageHandler) Handle(ctx context.Context, binaries []*modelg
packages[i].SourceID = r.sourceID
}
if len(vl) > 0 {
if _, err = r.g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: vl}); err != nil {
return pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
// if _, err = r.g.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: vl}); err != nil {
// return pb.ErrorErrorReasonUnspecified("%s", err.Error())
//}
if err = r.g.repo.UpsertAppPackages(ctx, r.sourceID, packages); err != nil {
return pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
Expand Down
15 changes: 7 additions & 8 deletions app/sephirah/internal/biz/bizgebura/gebura.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/tuihub/librarian/internal/lib/libcache"
"github.com/tuihub/librarian/internal/lib/libmq"
"github.com/tuihub/librarian/internal/model"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"

"github.com/go-kratos/kratos/v2/errors"
)
Expand Down Expand Up @@ -47,9 +46,9 @@ type GeburaRepo interface {
}

type Gebura struct {
auth *libauth.Auth
repo GeburaRepo
mapper mapper.LibrarianMapperServiceClient
auth *libauth.Auth
repo GeburaRepo
// mapper mapper.LibrarianMapperServiceClient
searcher *client.Searcher
updateAppIndex *libmq.Topic[modelangela.UpdateAppIndex]
pullApp *libmq.Topic[modelangela.PullApp]
Expand All @@ -59,16 +58,16 @@ type Gebura struct {
func NewGebura(
repo GeburaRepo,
auth *libauth.Auth,
mClient mapper.LibrarianMapperServiceClient,
// mClient mapper.LibrarianMapperServiceClient,
sClient *client.Searcher,
updateAppIndex *libmq.Topic[modelangela.UpdateAppIndex],
pullApp *libmq.Topic[modelangela.PullApp],
appCache *libcache.Map[modelgebura.AppID, modelgebura.App],
) *Gebura {
return &Gebura{
auth: auth,
repo: repo,
mapper: mClient,
auth: auth,
repo: repo,
//mapper: mClient,
searcher: sClient,
updateAppIndex: updateAppIndex,
pullApp: pullApp,
Expand Down
41 changes: 20 additions & 21 deletions app/sephirah/internal/biz/biztiphereth/tiphereth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/tuihub/librarian/internal/lib/libmq"
"github.com/tuihub/librarian/internal/lib/logger"
"github.com/tuihub/librarian/internal/model"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"
)

type TipherethRepo interface {
Expand Down Expand Up @@ -43,11 +42,11 @@ type TipherethRepo interface {
}

type Tiphereth struct {
app *libapp.Settings
auth *libauth.Auth
repo TipherethRepo
supv *supervisor.Supervisor
mapper mapper.LibrarianMapperServiceClient
app *libapp.Settings
auth *libauth.Auth
repo TipherethRepo
supv *supervisor.Supervisor
// mapper mapper.LibrarianMapperServiceClient
searcher *client.Searcher
pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo]
}
Expand All @@ -57,17 +56,17 @@ func NewTiphereth(
repo TipherethRepo,
auth *libauth.Auth,
supv *supervisor.Supervisor,
mClient mapper.LibrarianMapperServiceClient,
// mClient mapper.LibrarianMapperServiceClient,
sClient *client.Searcher,
pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo],
cron *libcron.Cron,
) (*Tiphereth, error) {
t := &Tiphereth{
app: app,
auth: auth,
repo: repo,
supv: supv,
mapper: mClient,
app: app,
auth: auth,
repo: repo,
supv: supv,
//mapper: mClient,
searcher: sClient,
pullAccount: pullAccount,
}
Expand Down Expand Up @@ -112,15 +111,15 @@ func (t *Tiphereth) CreateConfiguredAdmin() {
return
}
user.ID = id
if _, err = t.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: []*mapper.Vertex{
{
Vid: int64(user.ID),
Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
Prop: nil,
},
}}); err != nil {
return
}
// if _, err = t.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: []*mapper.Vertex{
// {
// Vid: int64(user.ID),
// Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
// Prop: nil,
// },
// }}); err != nil {
// return
//}
if err = t.repo.CreateUser(ctx, user, user.ID); err != nil {
logger.Infof("repo CreateUser failed: %s", err.Error())
return
Expand Down
19 changes: 9 additions & 10 deletions app/sephirah/internal/biz/biztiphereth/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/tuihub/librarian/internal/lib/libauth"
"github.com/tuihub/librarian/internal/lib/logger"
"github.com/tuihub/librarian/internal/model"
mapper "github.com/tuihub/protos/pkg/librarian/mapper/v1"
pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1"

"github.com/go-kratos/kratos/v2/errors"
Expand Down Expand Up @@ -39,15 +38,15 @@ func (t *Tiphereth) CreateUser(ctx context.Context, user *modeltiphereth.User) (
return nil, pb.ErrorErrorReasonUnspecified("%s", err)
}
user.ID = id
if _, err = t.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: []*mapper.Vertex{
{
Vid: int64(user.ID),
Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
Prop: nil,
},
}}); err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
// if _, err = t.mapper.InsertVertex(ctx, &mapper.InsertVertexRequest{VertexList: []*mapper.Vertex{
// {
// Vid: int64(user.ID),
// Type: mapper.VertexType_VERTEX_TYPE_ABSTRACT,
// Prop: nil,
// },
// }}); err != nil {
// return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
//}
if err = t.repo.CreateUser(ctx, user, claims.UserID); err != nil {
logger.Infof("repo CreateUser failed: %s", err.Error())
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
Expand Down
Loading

0 comments on commit 4cd88ab

Please sign in to comment.