-
Notifications
You must be signed in to change notification settings - Fork 2
*: Prepare the v2 #78
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
Conversation
xgoffin
left a comment
There was a problem hiding this 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 | |||
There was a problem hiding this comment.
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
| k := k | ||
|
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too but it is used as a fallback in umoney apparently https://github.com/upfluence/umoney/blob/7de3a2619ac667b91d5ecf3fbd97812a433efa45/client/rate_fetcher.go#L10
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return err | |
| return errors.WithStack(err) |
group/typed_group.go
Outdated
| func (tg *TypedGroup[T]) Do(fn TypedRunner[T]) { | ||
| tg.Group.Do(func(ctx context.Context) error { | ||
| fn, err := fn(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
syncutil/keyed_singleflight.go
Outdated
| } | ||
|
|
||
| for _, e := range es { | ||
| e := e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| e := e |
| } | ||
| } | ||
|
|
||
| return v, ok, nil |
There was a problem hiding this comment.
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.
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
cacheinterface 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
Additional Notes