Skip to content

Conversation

@bgentry
Copy link
Contributor

@bgentry bgentry commented May 7, 2025

This is a partial redesign of the job detail page to attempt to bring all attempt-related info into a single attempts list. This includes which worker ran the job, errors if they occurred, and any logs which may have been recorded with the new riverlog middleware. Side note: while building this, I realized this is undocumented in riverqueue.com/docs—we may want to fix that?

Screenshot 2025-05-06 at 9 46 57 PM

Currently based on #344 because the conflicts would have been annoying.

@bgentry bgentry requested a review from brandur May 7, 2025 02:49
ByKind bool `json:"by_kind"`
}

type RiverJobMinimal struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if you have another preferred pattern for this, but with the prospect for larger amounts of data being stored in metadata it doesn't seem like a great idea to fetch or render the entire thing into the API response. This was just a quick way to get unblocked and put the problem forward.

Actually the query itself is untouched here since we're just leveraging JobList, so it's fetching the payloads whether or not they're used. But still, the frontend doesn't need to keep these for a potentially long list of jobs being displayed, and then re-fetching it every few seconds.

Copy link

Choose a reason for hiding this comment

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

It is indeed the idiomatic way to segregate "exported" data to the dedicated struct.

Copy link
Collaborator

@brandur brandur May 8, 2025

Choose a reason for hiding this comment

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

We use a similar approach at work, even using the "minimal" moniker, but what do you think about embedding the minimal job on the main job like?

type RiverJob struct {
    RiverJobMinimal
}

The JSON fields end up at the same top level, but that way we don't need to maintain two completely duplicate lists of values, and it's obvious what's different in the minimal version versus non-minimal version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't remember whether it came out unnested or not in the JSON, so great news, I've made that switch.

ByKind bool `json:"by_kind"`
}

type RiverJobMinimal struct {
Copy link

Choose a reason for hiding this comment

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

It is indeed the idiomatic way to segregate "exported" data to the dedicated struct.

Copy link
Collaborator

@brandur brandur left a comment

Choose a reason for hiding this comment

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

Yes! Looking great.

This includes which worker ran the job, errors if they occurred, and any logs which may have been recorded with the new riverlog middleware.

Nice! Okay, I didn't check this because I don't have a great way locally of producing any test data, but in case the job does not error, does this approach give the user a way to see the logs for a non-error run?

Side note: while building this, I realized this is undocumented in riverqueue.com/docs—we may want to fix that?

Yeah, I was basically going to wait until there was UI support, but after this ships let's put them in for sure.

ByKind bool `json:"by_kind"`
}

type RiverJobMinimal struct {
Copy link
Collaborator

@brandur brandur May 8, 2025

Choose a reason for hiding this comment

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

We use a similar approach at work, even using the "minimal" moniker, but what do you think about embedding the minimal job on the main job like?

type RiverJob struct {
    RiverJobMinimal
}

The JSON fields end up at the same top level, but that way we don't need to maintain two completely duplicate lists of values, and it's obvious what's different in the minimal version versus non-minimal version.

Base automatically changed from bg-filter-jobs to master May 8, 2025 00:39
@bgentry bgentry enabled auto-merge (squash) May 8, 2025 00:49
@bgentry bgentry merged commit 9a8e2f2 into master May 8, 2025
12 checks passed
@bgentry bgentry deleted the bg-job-logs branch May 8, 2025 00:50
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.

4 participants