Skip to content

Commit

Permalink
feat: update proto to v0.4.23
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Sep 25, 2024
1 parent 93eafb0 commit 52a939b
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 17 deletions.
13 changes: 7 additions & 6 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.

8 changes: 7 additions & 1 deletion app/sephirah/internal/biz/bizangela/angela.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/tuihub/librarian/app/sephirah/internal/client"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelangela"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor"
"github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod"
"github.com/tuihub/librarian/app/sephirah/internal/supervisor"
Expand Down Expand Up @@ -36,6 +37,7 @@ var ProviderSet = wire.NewSet(
)

type Angela struct {
AngelaBase
mq *libmq.MQ
}
type AngelaBase struct {
Expand All @@ -58,6 +60,8 @@ type AngelaRepo interface {
UpdateFeedPullStatus(context.Context, *modelyesod.FeedConfig) error
GetFeedItem(context.Context, model.InternalID) (*modelfeed.Item, error)
GetFeedActions(context.Context, model.InternalID) ([]*modelyesod.FeedActionSet, error)
GetNotifyTargetItems(context.Context, model.InternalID, model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error)
AddFeedItemsToCollection(context.Context, model.InternalID, []model.InternalID) error
}

func NewAngelaBase(
Expand All @@ -79,6 +83,7 @@ func NewAngelaBase(
}

func NewAngela(
base *AngelaBase,
mq *libmq.MQ,
pullAccountInfo *libmq.Topic[modeltiphereth.PullAccountInfo],
pullAccountAppInfoRelation *libmq.Topic[modelangela.PullAccountAppInfoRelation],
Expand Down Expand Up @@ -114,6 +119,7 @@ func NewAngela(
return nil, err
}
return &Angela{
mq: mq,
AngelaBase: *base,
mq: mq,
}, nil
}
11 changes: 11 additions & 0 deletions app/sephirah/internal/biz/bizangela/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func NewNotifyRouterTopic( //nolint:gocognit // TODO
if len(messages) == 0 {
continue
}
itemIDs := make([]model.InternalID, 0, len(messages))
for _, item := range messages {
if item == nil {
continue
}
itemIDs = append(itemIDs, item.ID)
}
for _, target := range flow.Targets {
if target == nil {
continue
Expand All @@ -63,6 +70,10 @@ func NewNotifyRouterTopic( //nolint:gocognit // TODO
if err != nil {
return err
}
err = a.repo.AddFeedItemsToCollection(ctx, flowID, itemIDs)
if err != nil {
return err
}
}
}
return nil
Expand Down
23 changes: 23 additions & 0 deletions app/sephirah/internal/biz/bizangela/porter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package bizangela

import (
"context"

"github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor"
"github.com/tuihub/librarian/internal/lib/libauth"
"github.com/tuihub/librarian/internal/model"
"github.com/tuihub/librarian/internal/model/modelfeed"
)

func (a *Angela) PorterGetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) {
claims := libauth.FromContextAssertUserType(ctx, libauth.UserTypePorter)
if claims == nil {
return nil, nil, bizutils.NoPermissionError()
}
fr, items, err := a.repo.GetNotifyTargetItems(ctx, id, paging)
if err != nil {
return nil, nil, err
}
return fr, items, nil
}
42 changes: 42 additions & 0 deletions app/sephirah/internal/data/angela.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset"
"github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig"
"github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem"
"github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor"
"github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth"
"github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod"
"github.com/tuihub/librarian/internal/model"
Expand Down Expand Up @@ -315,3 +317,43 @@ func (a *angelaRepo) GetFeedActions(ctx context.Context, id model.InternalID) ([
}
return converter.ToBizFeedActionSetList(actions), nil
}

func (a *angelaRepo) GetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) {
var fr *modelsupervisor.FeatureRequest
var it []*modelfeed.Item
err := a.data.WithTx(ctx, func(tx *ent.Tx) error {
target, err := tx.NotifyTarget.Get(ctx, id)
if err != nil {
return err
}
fr = target.Destination
ids, err := target.QueryNotifyFlow().IDs(ctx)
if err != nil {
return err
}
items, err := tx.FeedItem.Query().Where(
feeditem.HasFeedItemCollectionWith(
feeditemcollection.IDIn(ids...),
),
).Offset(paging.ToOffset()).Limit(paging.ToLimit()).All(ctx)
if err != nil {
return err
}
it = converter.ToBizFeedItemList(items)
return nil
})
if err != nil {
return nil, nil, err
}
return fr, it, nil
}

func (a *angelaRepo) AddFeedItemsToCollection(
ctx context.Context,
collectionID model.InternalID,
itemIDs []model.InternalID,
) error {
return a.data.db.FeedItemCollection.UpdateOneID(collectionID).
AddFeedItemIDs(itemIDs...).
Exec(ctx)
}
6 changes: 6 additions & 0 deletions app/sephirah/internal/data/internal/converter/generated.go

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

11 changes: 11 additions & 0 deletions app/sephirah/internal/data/netzach.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ func (n *netzachRepo) CreateNotifyFlow(ctx context.Context, userID model.Interna
if err != nil {
return err
}
// For save flow items
err = tx.FeedItemCollection.Create().
SetOwnerID(userID).
SetID(f.ID).
SetName(f.Name).
SetDescription(f.Description).
SetCategory("").
Exec(ctx)
if err != nil {
return err
}
return nil
})
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions app/sephirah/internal/model/converter/generated.go

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

11 changes: 6 additions & 5 deletions app/sephirah/internal/model/modelsupervisor/modelsupervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ type PorterFeatureSummary struct {
}

type FeatureFlag struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ConfigJSONSchema string `json:"config_json_schema"`
RequireContext bool `json:"require_context"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ConfigJSONSchema string `json:"config_json_schema"`
RequireContext bool `json:"require_context"`
Extra map[string]string `json:"extra"`
}

func (f *FeatureFlag) Match(request *FeatureRequest) bool {
Expand Down
4 changes: 3 additions & 1 deletion app/sephirah/internal/service/librariansephirahservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
type LibrarianSephirahServiceService struct {
pb.UnimplementedLibrarianSephirahServiceServer

a *bizangela.Angela
t *biztiphereth.Tiphereth
g *bizgebura.Gebura
b *bizbinah.Binah
Expand All @@ -37,7 +38,7 @@ type LibrarianSephirahServiceService struct {
}

func NewLibrarianSephirahServiceService(
_ *bizangela.Angela,
a *bizangela.Angela,
t *biztiphereth.Tiphereth,
g *bizgebura.Gebura,
b *bizbinah.Binah,
Expand All @@ -58,6 +59,7 @@ func NewLibrarianSephirahServiceService(
}
res := &LibrarianSephirahServiceService{
UnimplementedLibrarianSephirahServiceServer: pb.UnimplementedLibrarianSephirahServiceServer{},
a: a,
t: t,
g: g,
b: b,
Expand Down
27 changes: 27 additions & 0 deletions app/sephirah/internal/service/porter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package service

import (
"context"

"github.com/tuihub/librarian/app/sephirah/internal/model/converter"
"github.com/tuihub/librarian/internal/model"
pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1"
)

func (s *LibrarianSephirahServiceService) PorterGetNotifyTargetItems(
ctx context.Context,
req *pb.PorterGetNotifyTargetItemsRequest,
) (*pb.PorterGetNotifyTargetItemsResponse, error) {
fr, items, err := s.a.PorterGetNotifyTargetItems(ctx,
converter.ToBizInternalID(req.GetId()),
model.ToBizPaging(req.GetPaging()),
)
if err != nil {
return nil, err
}
return &pb.PorterGetNotifyTargetItemsResponse{
Paging: nil,
Destination: converter.ToPBFeatureRequest(fr),
Items: converter.ToPBFeedItemList(items),
}, nil
}
2 changes: 1 addition & 1 deletion app/sephirah/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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/redis/go-redis/v9 v9.6.1
github.com/sony/sonyflake v1.2.0
github.com/stretchr/testify v1.9.0
github.com/tuihub/protos v0.4.22
github.com/tuihub/protos v0.4.23
github.com/zhihu/norm v0.1.11
go.opentelemetry.io/otel v1.29.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,8 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tuihub/protos v0.4.22 h1:HtbZSsA8/t1vzWXYKGqRIU07mVEn8v3mrbsllNAON6c=
github.com/tuihub/protos v0.4.22/go.mod h1:lmf29LH3wf7Fb0in47Q/ar2qf2V7ogckV6dnlBrsZ1I=
github.com/tuihub/protos v0.4.23 h1:qKRxguvvVbDNBPItSB3dGYxpz+lsex2sZDXt2NyT8rE=
github.com/tuihub/protos v0.4.23/go.mod h1:lmf29LH3wf7Fb0in47Q/ar2qf2V7ogckV6dnlBrsZ1I=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8/go.mod h1:OYRfF6eb5wY9VRFkXJH8FFBi3plw2v+giaIu7P054pM=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
Expand Down

0 comments on commit 52a939b

Please sign in to comment.