Hi Ankit, thanks for the Apache license and for sharing here. Here’s a code 
review.

These are my unfiltered opinions and I hope that they are useful.

Without looking at any code yet, the packages might not be idiomatic. 
Packages should contain specific behavior that can be decoupled from the 
application. These concepts could be represented as files and symbols in 
package main.

SQP_K_LISTENER_PORT might be more regularly represented as SQPKListenerPort.

In config_manager_test.go you could embed model.ServiceQProperties and 
error in type Properties for better readability.

The newlines in the functions don’t help readability.

Instead of this:

if sqp, err := getProperties(getPropertyFilePath()); err == nil {
…
} else {
    fmt.Fprintf(os.Stderr…

this may be more readable:

// or if …; err != nil {
sqp, err := getProperties(getPropertyFilePath())
if err != nil {
    fmt.Fprintf(os.Stderr…
    return
}
// regular functionality

Generally “err == nil” shouldn’t be in the code.

In getListener a similar improvement could be made to avoid the unnecessary 
indentation:

if sqp.SSLEnabled == false {
    return …
}
// longer behavior

In TestWorkAssignment the sqp could be simpler:

sqp := model.ServiceQProperty{
    ListenerPort: “5252”,
    Proto:        “http”,
    …

More if improvement in algorithm.ChooseServiceIndex:

if retry != 0 {
    return …
}
// longer behavior

The else after “if sumErr == 0” is unnecessary.

The mutex could be embedded in model.ServiceQProperties.

How did you validate this program?

Thanks,
Matt

On Friday, May 18, 2018 at 2:34:20 AM UTC-5, Ankit Gupta wrote:
>
> Hello gophers,
>
> I recently built a small HTTP load balancer with capabilities built around 
> error feedback - https://github.com/gptankit/serviceq
> Provides two primary functionalities - deferred request queue and 
> probabilitically reducing errored nodes selection.
>
> I am using channel as a in-memory data structure for storing deferred 
> requests. Would love some feedback on this approach and on the project in 
> general.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to