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

Add the ability to export events for a subset of projects and from a starting offset #4701

Merged
merged 7 commits into from
Jan 31, 2024

Conversation

imsdu
Copy link
Contributor

@imsdu imsdu commented Jan 26, 2024

Fixes #4662

@imsdu imsdu added delta and removed delta labels Jan 26, 2024
)
} yield ExportResult(exportFile, exportSuccess, start, end)

semaphore.permit.use { _ => exportIO }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use a semaphore so that exports don't consume all connections

_ <- exportToFile(q, exportFile)
end <- clock.realTimeInstant
exportSuccess = targetDirectory / s"$start.success"
_ <- Files[IO].createFile(exportSuccess)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This marker file allows to know that the export succeeded.
If we plan to sync those files, this allows to know the state without an additional api call

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this file could contain the input payload + when it started / ended? So that we know what projects are included at a glance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea to put the query in it.
The starting time is encoded in the name and the end will be the creation time of that file.
Ok to just include the query for now ?


import scala.annotation.nowarn

final case class ExportEventQuery(id: Label, projects: NonEmptyList[ProjectRef], offset: Offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is id anything other than the folder containing export files? Might be clearer to name it that

_ <- exportToFile(q, exportFile)
end <- clock.realTimeInstant
exportSuccess = targetDirectory / s"$start.success"
_ <- Files[IO].createFile(exportSuccess)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this file could contain the input payload + when it started / ended? So that we know what projects are included at a glance

extractCaller { implicit caller =>
(post & pathEndOrSingleSlash & entity(as[ExportEventQuery])) { query =>
authorizeFor(AclAddress.Root, Permissions.exporter.run).apply {
emit(StatusCodes.Accepted, exporter.events(query).start.void)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be interesting later to have a way of knowing a failure in the export occurred?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, to be discussed like reporting in general

@imsdu imsdu merged commit afd36df into BlueBrain:master Jan 31, 2024
7 checks passed
@imsdu imsdu deleted the 4662-add-export-feature branch January 31, 2024 08:15
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.

Export selected scoped events in a file
3 participants