Skip to content

Commit

Permalink
Merge pull request #2083 from ConnorJC3/remove-comparable-coalescer
Browse files Browse the repository at this point in the history
Change coalescer InputType from `comparable` to `any`
  • Loading branch information
k8s-ci-robot committed Jul 8, 2024
2 parents a789247 + d35e5aa commit 1ab7c79
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/coalescer/coalescer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// When the delay on the request expires (determined by the time the first request comes in), the merged
// input is passed to the execution function, and the result to all waiting callers (those that were
// not rejected during the merge step)
type Coalescer[InputType comparable, ResultType any] interface {
type Coalescer[InputType any, ResultType any] interface {
// Coalesce is a function to coalesce a given input
// key = only requests with this same key will be coalesced (such as volume ID)
// input = input to merge with other inputs
Expand All @@ -46,7 +46,7 @@ type Coalescer[InputType comparable, ResultType any] interface {
// (should return an error if the new input cannot be combined with the existing inputs,
// otherwise return the new merged input)
// executeFunction = the function to call when the delay expires
func New[InputType comparable, ResultType any](delay time.Duration,
func New[InputType any, ResultType any](delay time.Duration,
mergeFunction func(input InputType, existing InputType) (InputType, error),
executeFunction func(key string, input InputType) (ResultType, error),
) Coalescer[InputType, ResultType] {
Expand All @@ -71,19 +71,19 @@ type result[ResultType any] struct {

// Type to send inputs from Coalesce() to coalescerThread() via channel
// Includes a return channel for the result
type newInput[InputType comparable, ResultType any] struct {
type newInput[InputType any, ResultType any] struct {
key string
input InputType
resultChannel chan result[ResultType]
}

// Type to store pending inputs in the input map
type pendingInput[InputType comparable, ResultType any] struct {
type pendingInput[InputType any, ResultType any] struct {
input InputType
resultChannels []chan result[ResultType]
}

type coalescer[InputType comparable, ResultType any] struct {
type coalescer[InputType any, ResultType any] struct {
delay time.Duration
mergeFunction func(input InputType, existing InputType) (InputType, error)
executeFunction func(key string, input InputType) (ResultType, error)
Expand Down

0 comments on commit 1ab7c79

Please sign in to comment.