Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmd/queryer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"os"

"github.com/L4B0MB4/EVTSRC/pkg/client"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/eventpolling"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/eventhandling"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/httphandler"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/httphandler/controller"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/store"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/store/repository"
"github.com/PRYVT/utils/pkg/auth"
"github.com/PRYVT/utils/pkg/eventpolling"
utilsRepo "github.com/PRYVT/utils/pkg/store/repository"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
Expand All @@ -35,13 +37,15 @@ func main() {
log.Error().Err(err).Msg("Unsuccessful initialization of token manager")
return
}
eventRepo := repository.NewEventRepository(conn)
eventRepo := utilsRepo.NewEventRepository(conn)
userRepo := repository.NewUserRepository(conn)
uc := controller.NewUserController(userRepo, tokenManager)
aut := auth.NewAuthMiddleware(tokenManager)
h := httphandler.NewHttpHandler(uc, aut)

eventPolling := eventpolling.NewEventPolling(c, eventRepo, userRepo)
userEventHandler := eventhandling.NewUserEventHandler(userRepo)

eventPolling := eventpolling.NewEventPolling(c, eventRepo, userEventHandler)
go eventPolling.PollEvents()

h.Start()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require github.com/mattn/go-sqlite3 v1.14.24

require (
github.com/L4B0MB4/EVTSRC v0.4.5 // indirect
github.com/PRYVT/utils v0.1.2 // indirect
github.com/PRYVT/utils v0.2.0 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/PRYVT/utils v0.1.1 h1:Y/WHkTHID0T40O2XfzlLM1QsDyQWE8FtH8ncaU4ags8=
github.com/PRYVT/utils v0.1.1/go.mod h1:b7zk2FAGwJ8BPJx2JQ8qd+bA59g5EY7Y1vZQPWZHK3s=
github.com/PRYVT/utils v0.1.2 h1:U9qhq+18iIblQDrM4I0fmJkvlZ+BCY+DIjjKI4ebtlk=
github.com/PRYVT/utils v0.1.2/go.mod h1:b7zk2FAGwJ8BPJx2JQ8qd+bA59g5EY7Y1vZQPWZHK3s=
github.com/PRYVT/utils v0.2.0 h1:hWdHchXlGOYlJ1nfMmGffq/EjFn3ncvzTgsGCLUpiEE=
github.com/PRYVT/utils v0.2.0/go.mod h1:j61GmoyWWXgnCq/laZTIJm4yhD0PreLDMZnYQqjSv7w=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg=
Expand Down
35 changes: 35 additions & 0 deletions pkg/query/eventhandling/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package eventhandling

import (
"github.com/L4B0MB4/EVTSRC/pkg/models"
"github.com/L4B0MB4/PRYVT/identification/pkg/aggregates"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/store/repository"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)

type UserEventHandler struct {
userRepo *repository.UserRepository
}

func NewUserEventHandler(userRepo *repository.UserRepository) *UserEventHandler {
return &UserEventHandler{
userRepo: userRepo,
}
}

func (eh *UserEventHandler) HandleEvent(event models.Event) error {
if event.AggregateType == "user" {
ua, err := aggregates.NewUserAggregate(uuid.MustParse(event.AggregateId))
if err != nil {
return err
}
uI := aggregates.GetUserModelFromAggregate(ua)
err = eh.userRepo.AddOrReplaceUser(uI)
if err != nil {
log.Err(err).Msg("Error while processing user event")
return err
}
}
return nil
}
75 changes: 0 additions & 75 deletions pkg/query/eventpolling/polling.go

This file was deleted.

66 changes: 0 additions & 66 deletions pkg/query/store/repository/event_repository.go

This file was deleted.