diff --git a/cmd/queryer/main.go b/cmd/queryer/main.go index e5bca0f..1b07857 100644 --- a/cmd/queryer/main.go +++ b/cmd/queryer/main.go @@ -53,12 +53,10 @@ func main() { eventPolling.PollEventsUntilEmpty() go func() { - for { - select { - case event := <-channel: - log.Info().Msgf("Received event: %s", event) - eventPolling.PollEventsUntilEmpty() - } + for event := range channel { + log.Info().Msgf("Received event: %s", event) + eventPolling.PollEventsUntilEmpty() + log.Debug().Msg("New event received finished") } }() h.Start() diff --git a/go.mod b/go.mod index f421eaf..8313942 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/PRYVT/posting go 1.23.1 require ( - github.com/L4B0MB4/EVTSRC v0.5.2 // indirect + github.com/L4B0MB4/EVTSRC v0.5.4 // indirect github.com/PRYVT/utils v0.3.0-rc // indirect github.com/bytedance/sonic v1.12.2 // indirect github.com/bytedance/sonic/loader v0.2.0 // indirect diff --git a/go.sum b/go.sum index d54126c..efacb0d 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/L4B0MB4/EVTSRC v0.5.1 h1:EB/lK0FTWtepToOtRFJdUhBf6tlb1L0bIRbRTMwArsQ= github.com/L4B0MB4/EVTSRC v0.5.1/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0= github.com/L4B0MB4/EVTSRC v0.5.2 h1:bAOYlUmcZ2bg8rWIKnHLnxZPgXrPYyrQbtlz49BKlp4= github.com/L4B0MB4/EVTSRC v0.5.2/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0= +github.com/L4B0MB4/EVTSRC v0.5.4 h1:bTg1PS78YzWb+dt3JJRFFVNMubIAiKJlO3Ivdy7jagc= +github.com/L4B0MB4/EVTSRC v0.5.4/go.mod h1:hpyNdNWqikZ6dcm8dhZAXgnAXZQNGAfXgRw902zjby0= 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= diff --git a/pkg/query/eventhandling/post.go b/pkg/query/eventhandling/post.go index e255d1b..4485767 100644 --- a/pkg/query/eventhandling/post.go +++ b/pkg/query/eventhandling/post.go @@ -41,7 +41,9 @@ func removeDisconnectedSockets(slice []*ws.WebsocketConnection) []*ws.WebsocketC } func (eh *PostEventHandler) HandleEvent(event models.Event) error { + log.Debug().Msg("Handling event") if event.AggregateType == "post" { + log.Debug().Msg("Handling post event") ua, err := aggregates.NewPostAggregate(uuid.MustParse(event.AggregateId)) if err != nil { return err @@ -64,7 +66,7 @@ func (eh *PostEventHandler) HandleEvent(event models.Event) error { eh.mu.Lock() defer eh.mu.Unlock() eh.wsConnections = removeDisconnectedSockets(eh.wsConnections) - + log.Trace().Msgf("Number of active connections: %d", len(eh.wsConnections)) } return nil } diff --git a/pkg/query/websocket/websocket_connection.go b/pkg/query/websocket/websocket_connection.go index 3c10ace..0f34768 100644 --- a/pkg/query/websocket/websocket_connection.go +++ b/pkg/query/websocket/websocket_connection.go @@ -45,6 +45,7 @@ func (wC *WebsocketConnection) ReadForDisconnect() { wC.IsConnected = false break } else { + log.Debug().Interface("authReq", authRequest).Msg("Received auth request") _, err = auth.VerifyToken(authRequest.Token) if err != nil { log.Debug().Err(err).Msg("Error while verifying token")