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 missing doc for JobRow.UniqueStates + reveal rivertype.UniqueOptsByStateDefault() #707

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Dec 27, 2024

Two small ones related to unique job insertion:

  • Adding a missing doc comment on JobRow.UniqueStates.

  • As discussed in Correct Way to Enforce Uniqueness on Insertion By Kind and Default States #704, reveal a way for end users to get the default
    set of unique job states via rivertype.UniqueOptsByStateDefault().
    Similar to rivertype.JobStates(), this is revealed as a function so
    that it's not possible to accidentally mutate a global slice. (Go:
    readonly variables would sure be pretty nice.)

@brandur brandur force-pushed the brandur-default-by-state branch from f92b992 to 2db15aa Compare December 27, 2024 00:26
…ptsByStateDefault()`

Two small ones related to unique job insertion:

* Adding a missing doc comment on `JobRow.UniqueStates`.

* As discussed in #704, reveal a way for end users to get the default
  set of unique job states via `rivertype.UniqueOptsByStateDefault()`.
  Similar to `rivertype.JobStates()`, this is revealed as a function so
  that it's not possible to accidentally mutate a global slice. (Go:
  readonly variables would sure be pretty nice.)
@brandur brandur force-pushed the brandur-default-by-state branch from 2db15aa to 8120584 Compare December 27, 2024 00:29
@brandur brandur requested a review from bgentry December 27, 2024 00:29
// UniqueOpts.ByState. So for example, with this default set a new unique job
// may be inserted even if another job already exists, as long as that other job
// is set `cancelled` or `discarded`.
func UniqueOptsByStateDefault() []JobState {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming on this one seems a little awkward, but I think it might be the best way to go: it's basically UniqueOpts + ByState + Default so it copies the taxonomy of the field it's being set to.

@brandur brandur merged commit 0d33bc1 into master Dec 27, 2024
10 checks passed
@brandur brandur deleted the brandur-default-by-state branch December 27, 2024 03:38
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