Files
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

90 lines
1.8 KiB
Go

package queues
import (
"fmt"
"go.temporal.io/server/service/history/tasks"
)
type (
Range struct {
InclusiveMin tasks.Key
ExclusiveMax tasks.Key
}
)
func NewRange(
inclusiveMin tasks.Key,
exclusiveMax tasks.Key,
) Range {
if inclusiveMin.CompareTo(exclusiveMax) > 0 {
panic(fmt.Sprintf("invalid task range, min %v is larger than max %v", inclusiveMin, exclusiveMax))
}
return Range{
InclusiveMin: inclusiveMin,
ExclusiveMax: exclusiveMax,
}
}
func (r *Range) IsEmpty() bool {
return r.InclusiveMin.CompareTo(r.ExclusiveMax) == 0
}
func (r *Range) ContainsKey(
key tasks.Key,
) bool {
return key.CompareTo(r.InclusiveMin) >= 0 &&
key.CompareTo(r.ExclusiveMax) < 0
}
func (r *Range) ContainsRange(
input Range,
) bool {
return r.InclusiveMin.CompareTo(input.InclusiveMin) <= 0 &&
r.ExclusiveMax.CompareTo(input.ExclusiveMax) >= 0
}
func (r *Range) CanSplit(
key tasks.Key,
) bool {
return r.ContainsKey(key) || r.ExclusiveMax.CompareTo(key) == 0
}
func (r *Range) Split(
key tasks.Key,
) (left Range, right Range) {
if !r.CanSplit(key) {
panic(fmt.Sprintf("Unable to split range %v at %v", r, key))
}
return NewRange(r.InclusiveMin, key), NewRange(key, r.ExclusiveMax)
}
func (r *Range) CanMerge(
input Range,
) bool {
return r.InclusiveMin.CompareTo(input.ExclusiveMax) <= 0 &&
r.ExclusiveMax.CompareTo(input.InclusiveMin) >= 0
}
func (r *Range) Merge(
input Range,
) Range {
if !r.CanMerge(input) {
panic(fmt.Sprintf("Unable to merge range %v with incoming range %v", r, input))
}
return NewRange(
tasks.MinKey(r.InclusiveMin, input.InclusiveMin),
tasks.MaxKey(r.ExclusiveMax, input.ExclusiveMax),
)
}
func (r *Range) Equals(
input Range,
) bool {
return r.InclusiveMin.CompareTo(input.InclusiveMin) == 0 &&
r.ExclusiveMax.CompareTo(input.ExclusiveMax) == 0
}