Skip to content

Commit

Permalink
Integrate TCP event client and update event polling mechanism for imp…
Browse files Browse the repository at this point in the history
…roved event handling
  • Loading branch information
L4B0MB4 committed Nov 30, 2024
1 parent ed40154 commit afb346c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
20 changes: 19 additions & 1 deletion cmd/queryer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"

"github.com/L4B0MB4/EVTSRC/pkg/client"
tcpClient "github.com/L4B0MB4/EVTSRC/pkg/tcp/client"
"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"
Expand Down Expand Up @@ -46,7 +47,24 @@ func main() {
userEventHandler := eventhandling.NewUserEventHandler(userRepo)

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

tcpC, err := tcpClient.NewTcpEventClient()
if err != nil {
log.Error().Err(err).Msg("Unsuccessful initialization of tcp client")
return
}
channel := make(chan string, 1)
go tcpC.ListenForEvents(channel)

eventPolling.PollEventsUntilEmpty()
go func() {
for {
select {
case event := <-channel:
log.Info().Msgf("Received event: %s", event)
eventPolling.PollEventsUntilEmpty()
}
}
}()
h.Start()
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.23.1
require github.com/mattn/go-sqlite3 v1.14.24

require (
github.com/L4B0MB4/EVTSRC v0.4.5 // indirect
github.com/PRYVT/utils v0.2.0 // indirect
github.com/L4B0MB4/EVTSRC v0.5.1 // indirect
github.com/PRYVT/utils v0.2.0-rc-2 // 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
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@ github.com/L4B0MB4/EVTSRC v0.4.0 h1:Y0/oEoMAv9kgGH/dgN9v1YBno6ZghXbWNPixScz9CX8=
github.com/L4B0MB4/EVTSRC v0.4.0/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.4.5 h1:HA4tp4fa/oCPTCl3gTD2FkRjo+nFKWm4rLmpudxcxXg=
github.com/L4B0MB4/EVTSRC v0.4.5/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-1 h1:r8FLKDAnFh0rOZVXTqBB9uQRu800MpAQoszNpW9g+QQ=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-1/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-2 h1:fTuKRKwmhshP3PYkq1Gu/3pywAKcbGGUo/okhZEfGe8=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-2/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-3 h1:bI9Fhh0zq6zU3lVCYBynpYhZb91g1o4hsZ703RCMkn8=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-3/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-4 h1:gUFnWbNnxlk3yYKKs1ymjySYoVyDyWbk0cmXZ3vyWcg=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-4/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-5 h1:CT3eZqVq2b4ghoG5g5bvvrcXZUGVy3AQoV3NAZ12Al0=
github.com/L4B0MB4/EVTSRC v0.5.0-rc-5/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/L4B0MB4/EVTSRC v0.5.1 h1:EB/lK0FTWtepToOtRFJdUhBf6tlb1L0bIRbRTMwArsQ=
github.com/L4B0MB4/EVTSRC v0.5.1/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0=
github.com/PRYVT/utils v0.1.0 h1:Oq/sKHTKBVoAX+pLJMniYaZfv0ReDlQ+5E8qpKGiVjI=
github.com/PRYVT/utils v0.1.0/go.mod h1:RDgZFSTf1GPnpjVqnw0PSY68bzyp+WTK/wgAklOBFxY=
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-rc-1 h1:CwYscVZqozFxc8vdtZnoNv6XYfu7RPODZ7g3ecNvKPE=
github.com/PRYVT/utils v0.2.0-rc-1/go.mod h1:j61GmoyWWXgnCq/laZTIJm4yhD0PreLDMZnYQqjSv7w=
github.com/PRYVT/utils v0.2.0-rc-2 h1:7fp2kgp22HIQxBCNrYStxPuiReCwbgrqIuWCZ0pBsBM=
github.com/PRYVT/utils v0.2.0-rc-2/go.mod h1:j61GmoyWWXgnCq/laZTIJm4yhD0PreLDMZnYQqjSv7w=
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=
Expand Down

0 comments on commit afb346c

Please sign in to comment.