Skip to content

Conversation

@AlexisMontagne
Copy link
Member

What does this PR do?

Prepare the v2 version of this repository.

There is two goals for this v2.

  • Simplifying the dependency graph. Over the years this repository has became a hodge podge of multiple library all stitched together and creating a dependency hells for libraries depending on it (looking at you lock/etcd). From now on this repo will only depend on the std lib, golang.org/x pkgs and our standard packages (upfuence/log,stats,cfg,errors)

  • Using generics, certains data structures were really crying to be using generics, looking at the cache interface mainly. But not only singleflights, balancer, resolver and other iopool will benefit from it.

*Clean up junk from the last 10 years. Some libraries were not used anymore, a new major version is a good time to do some spring cleaning.

What are the observable changes?

Good PR checklist

  • Title makes sense
  • Is against the correct branch
  • Only addresses one issue
  • Properly assigned
  • Added/updated tests
  • Added/updated documentation
  • Properly labeled

Additional Notes

@AlexisMontagne AlexisMontagne self-assigned this Sep 18, 2025
@AlexisMontagne AlexisMontagne requested a review from a team as a code owner September 18, 2025 18:29
@AlexisMontagne AlexisMontagne requested review from pauloestrella1994 and xgoffin and removed request for a team September 18, 2025 18:29
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@xgoffin xgoffin left a comment

Choose a reason for hiding this comment

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

Not sure about it all but nice to ditch that much code

go.mod Outdated
@@ -5,27 +5,6 @@ go 1.23.0
toolchain go1.23.1
Copy link
Contributor

Choose a reason for hiding this comment

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

do we wanna bump this?

group/map.go Outdated
Comment on lines 18 to 19
k := k

Copy link
Contributor

Choose a reason for hiding this comment

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

🙈


const apiURL = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"

type RateFetcher struct {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to delete this one? Since we have umoney now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

@Sypheos Sypheos Sep 22, 2025

Choose a reason for hiding this comment

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

Probably better to move it there then

Copy link
Member Author

Choose a reason for hiding this comment

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

id rather keep it here, as it only relies on the stdlib and umoney is private (and not this one). This can be used off the shelve in any situation

}

func (b *Balancer) Get(ctx context.Context, opts balancer.GetOptions) (peer.Peer, error) {
func (b *Balancer[T]) Get(ctx context.Context, opts balancer.GetOptions) (T, func(error), error) {
Copy link
Member

Choose a reason for hiding this comment

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

func(error) is either nil or does nothing. Is it needed ?

Copy link
Member Author

@AlexisMontagne AlexisMontagne Sep 22, 2025

Choose a reason for hiding this comment

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

Yep not quite yet, as i was messing with the interface better do it all the way 😅. My goal is to make loadbalancer error aware. Ideally LB policies that can reduce the occurrence of a peer picking if it becomes faulty.

The goal of this PR was only to prepare for a new version: Break interfaces & delete old code. Not add new one

group/map.go Outdated
var v, err = fn(ctx, k)

if err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return err
return errors.WithStack(err)

Comment on lines 17 to 19
func (tg *TypedGroup[T]) Do(fn TypedRunner[T]) {
tg.Group.Do(func(ctx context.Context) error {
fn, err := fn(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (tg *TypedGroup[T]) Do(fn TypedRunner[T]) {
tg.Group.Do(func(ctx context.Context) error {
fn, err := fn(ctx)
func (tg *TypedGroup[T]) Do(runner TypedRunner[T]) {
tg.Group.Do(func(ctx context.Context) error {
fn, err := runner(ctx)

}

for _, e := range es {
e := e
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
e := e

}
}

return v, ok, nil
Copy link

Choose a reason for hiding this comment

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

Bug: Cache Error Handling Causes Missinterpretation

The Get method now incorrectly returns ok=false whenever an error occurs, whether from the underlying cache or the eviction policy operation. Previously, ok indicated if the item was found in the cache, independent of other errors. This change can cause callers to misinterpret cache hits (with an error) as cache misses.

Fix in Cursor Fix in Web

@AlexisMontagne AlexisMontagne merged commit e762742 into master Sep 22, 2025
5 checks passed
@AlexisMontagne AlexisMontagne deleted the v2.x branch September 22, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants