Skip to content

[suggestion] Make ProxyBalancer interface Next() method return error as well #2313

Closed
@Hristov821

Description

@Hristov821
Use case:

Currently I need to forward request from my server to another ones. Unfortunatly I can not know in advance their urls (as suggested in documentation) as I need to make some calculations based on provided path and other rules.

What I did:

I created custom struct that satisfies ProxyBalancer interface

It works great but if I encounter error during the selection of next ProxyTarget it can't report the error and I need to panic, thus I would like to change the ProxyBalancer interface from:

ProxyBalancer interface {
	AddTarget(*ProxyTarget) bool
	RemoveTarget(string) bool
	Next(echo.Context) *ProxyTarget
}

to

ProxyBalancer interface {
	AddTarget(*ProxyTarget) bool
	RemoveTarget(string) bool
	Next(echo.Context) (*ProxyTarget, error)
}

The interface is used only in proxy.go, so the change IMO wont hurt.

If the change makes sense I could provide the necessary changes in PR.

Thanks in advance for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions