Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: project viewed events to be tackled in chunks #1729

Merged
merged 44 commits into from
Oct 6, 2023

Conversation

jachro
Copy link
Contributor

@jachro jachro commented Sep 28, 2023

This PR adds a new queue-like mechanism to deal with the ProjectViewed events in chunks instead of separately.

/deploy

closes #1649

@jachro jachro deployed to renku-ci-gr-1729 October 5, 2023 11:17 — with GitHub Actions Active
@jachro jachro marked this pull request as ready for review October 5, 2023 11:30
@jachro jachro requested a review from a team as a code owner October 5, 2023 11:30
Copy link
Member

@eikek eikek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! 🚀


private def returnToQueue(de: DequeuedEvent): Throwable => F[Unit] =
Logger[F].error(_)(show"$categoryName: persisting event failed: ${de.id}; returning to the queue") >>
eventsDequeuer.returnToQueue(de)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds a bit strange to me to have separate interfaces for deqeue and enqueue but then the dequeue also puts something into the queue?

import io.renku.triplesstore.{ProjectsConnectionConfig, SparqlQueryTimeRecorder}
import org.typelevel.log4cats.Logger

private trait EventProcessor[F[_]] extends Pipe[F, DequeuedEvent, DequeuedEvent]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why we need to return an event - so why it's not Pipe[F, Event, Unit], more of a sink?

SqlStatement
.named(s"$queryPrefix stats")
.select[Void, (CategoryName, Long)](
sql"""SELECT category, COUNT(id) AS count
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have now the stuff in the DbInfra object, we could use it here as well maybe?

SqlStatement
.named(s"$queryPrefix insert")
.command[CategoryName *: String *: OffsetDateTime *: OffsetDateTime *: EnqueueStatus *: EmptyTuple](
sql"""INSERT INTO enqueued_event (category, payload, created, updated, status)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here it seems we could use references to DbInfra perhaps?

private[viewed] def kickOffEventsDequeueing[F[_]: Async: Logger](dequeuer: EventsDequeuer[F],
processor: EventProcessor[F]
) = Async[F].start {
Logger[F].info(show"Starting events enqueuer for $categoryName") >>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo: "Starting events enqueuer" -> "Starting events dequeuer" ?

@jachro jachro deployed to renku-ci-gr-1729 October 6, 2023 07:51 — with GitHub Actions Active
@jachro jachro deployed to renku-ci-gr-1729 October 6, 2023 08:58 — with GitHub Actions Active
@jachro jachro merged commit 1ede4e5 into development Oct 6, 2023
@jachro jachro deleted the 1649-project-viewed-queue branch October 6, 2023 09:52
@jachro jachro mentioned this pull request Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A queue for the PROJECT_VIEWED events
3 participants