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

Replace Envelope with Elem.SuccessElem #4629

Merged
merged 11 commits into from
Jan 12, 2024
Merged

Conversation

dantb
Copy link
Contributor

@dantb dantb commented Jan 8, 2024

Fixes #3745

private def toIndexViewDef(envelope: Envelope[BlazegraphViewState]) =
envelope.toElem { v => Some(v.project) }.traverse { v =>
private def toIndexViewDef(elem: Elem.SuccessElem[BlazegraphViewState]) =
elem.withProject(elem.value.project).traverse { v =>
Copy link
Contributor Author

@dantb dantb Jan 8, 2024

Choose a reason for hiding this comment

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

Doesn't feel great that this is optional - most of the concrete types for which we're querying elems have a project and it's a mandatory field in the scoped tables. I guess it's because Envelope was used for both global and scoped?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's confusing how the elem wouldn't already have the project set since it's coming from within it..?

Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to populate this field from the original SQL query.
Yes, it was because Envelope and Elem were designed to work for both global and scoped entities.
Not sure if there is still a use case for global entities though now that we got rid of the sse events for them.

Copy link
Contributor

@shinyhappydan shinyhappydan left a comment

Choose a reason for hiding this comment

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

What was a stream of Envelopes, and what is a stream of SuccessElems?

private def toIndexViewDef(envelope: Envelope[BlazegraphViewState]) =
envelope.toElem { v => Some(v.project) }.traverse { v =>
private def toIndexViewDef(elem: Elem.SuccessElem[BlazegraphViewState]) =
elem.withProject(elem.value.project).traverse { v =>
Copy link
Contributor

Choose a reason for hiding this comment

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

It's confusing how the elem wouldn't already have the project set since it's coming from within it..?

@dantb dantb force-pushed the envelope-to-elem branch from 72c45d8 to 3ef239e Compare January 9, 2024 13:41
@dantb
Copy link
Contributor Author

dantb commented Jan 10, 2024

Looking into why the project was optional led me to try to understand the usage of elem / envelope before... My feeling is it's used in places it shouldn't be which leads to incidental complexity like streams of Elem where nothing on the Elem is ever used. The usages I've seen:

  1. Streaming from global tables. Now we use GlobalStateValue purely for the Read instance when streaming from global_states. Only value is needed.
  2. Streaming from scoped tables. This seems fine. However for the projections, the coordinators were using a stream of Elem rather than SuccessElem for views. This meant the type suggested that there could be failing / dropped elements, but there would never be. I've changed that now.
  3. Streaming from projection_restarts. No project here, I haven't modified this.
  4. Streaming from composite_restarts. There is a project here.
  5. Streaming graph resources - haven't yet gone down this rabbit hole.

3 and 5 mean the project remains optional. I don't understand enough to comment on what should be used and where, but it's still pretty confusing in its current state. So I still can't really answer your question @shinyhappydan 😂 maybe @imsdu can!

Also deleted a load of unused streaming methods from the event stores and logs. Probably enough for now!

private def states(offset: Offset, strategy: RefreshStrategy): EnvelopeStream[S] =
StreamingQuery[Envelope[S]](
private def states(offset: Offset, strategy: RefreshStrategy): Stream[IO, S] =
StreamingQuery[GlobalStateValue[S]](
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could use a tuple (S, Offset) here ?
Or make GlobalStateValueprivate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, less code!

@dantb dantb merged commit 783ec49 into BlueBrain:master Jan 12, 2024
5 checks passed
@dantb dantb deleted the envelope-to-elem branch January 12, 2024 09:35
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.

Remove envelope for elem
3 participants