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

[scd] oir upsert: factor out extension and validation of existing subscription #1098

Merged

Conversation

Shastick
Copy link
Contributor

@Shastick Shastick commented Sep 3, 2024

Another step towards #1088

@Shastick Shastick force-pushed the oir-upsert-refactor-2b-use-adapt-existing branch 2 times, most recently from 3251ac8 to 884cce3 Compare September 3, 2024 15:56
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

TBH I'm a bit less convinced by factoring away this function, its abstraction isn't very clear, its name and arguments are an indication of that.
I'm also not sure it is worth spending the time refactoring it more.
Now I don't think it makes anything worse than it is currently either.
So I'm OK merging the PR (after addressing the comment), but also OK not merging it, up to you.

if err != nil {
return stacktrace.Propagate(err, "Failed to update existing Subscription")
}
// Propagating the code here is important for properly handling all failure cases in the caller
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the simple Propagate does that in any case? I thought the error code would be unwrapped at the top of the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right: if the passed cause has a code, it will be re-used.

(But, for the record, if it has none, there will be no attempt to go look a level deeper for a code)

return nil, stacktrace.NewError("Cannot depend on a non-specified Subscription")
}

sub, err := r.GetSubscription(context.Background(), params.subscriptionID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Context of function must be used here.

@Shastick
Copy link
Contributor Author

Shastick commented Sep 6, 2024

TBH I'm a bit less convinced by factoring away this function, its abstraction isn't very clear, its name and arguments are an indication of that. I'm also not sure it is worth spending the time refactoring it more. Now I don't think it makes anything worse than it is currently either. So I'm OK merging the PR (after addressing the comment), but also OK not merging it, up to you.

Ideally, I'd like to have the whole body of the action (action := func(ctx context.Context, r repos.Repository) (err error) {...) only be calls to methods with reasonably descriptive names to provide readers with a high-level sense of what goes on.

In this case, the main thing I'd like to hide away is the extension of the implicit subscription.

In that regard, dependOnExistingSubscriptionIfAllowedAndCovered might do too many things.

I'll make a new proposal where that method is split in two.

@Shastick Shastick force-pushed the oir-upsert-refactor-2b-use-adapt-existing branch 2 times, most recently from 85f32c9 to 6f7b964 Compare September 6, 2024 10:26
@Shastick
Copy link
Contributor Author

Shastick commented Sep 6, 2024

@mickmis the PR now contains a proposal that hides away less logic

Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

Looks like the case for the start time got lost along the way.
Except from that LGTM indeed it is better that way IMO.

@Shastick Shastick force-pushed the oir-upsert-refactor-2b-use-adapt-existing branch from 6f7b964 to 9fc5b01 Compare September 6, 2024 12:57
@Shastick Shastick force-pushed the oir-upsert-refactor-2b-use-adapt-existing branch from 9fc5b01 to af03e7e Compare September 6, 2024 12:58
@mickmis mickmis merged commit 32f570b into interuss:master Sep 6, 2024
6 checks passed
@mickmis mickmis deleted the oir-upsert-refactor-2b-use-adapt-existing branch September 6, 2024 13:05
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.

2 participants