Giter Club home page Giter Club logo

grelay's Introduction

grelay's People

Contributors

edualb avatar qjuanp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

grelay's Issues

update to go 1.18.0

Is your feature request related to a problem? Please describe.

  • No. With the release of go 1.18, we want to use this version in our project to keep it updated. You can check all release notes here: https://tip.golang.org/doc/go1.18

Describe the solution you'd like

  • Update our go.mod file with the new version
  • Update our code with all necessary modifications to keep working with go 1.18.0

Describe alternatives you've considered

  • N/A

Additional context

  • N/A

Include WithGo method config

Is your feature request related to a problem? Please describe.

In gRelay v0.0.x the default config is using goroutines which costs a lot of memory allocation as you can see in benchmark folder. To improve our future features, we need to do a refactor in our system.

Describe the solution you'd like

We would like to have an interface:

type grelayExec interface {
	exec(service GrelayService, func() (interface{}, error)) (interface{}, error)
}

and an implementation of this interface:

type grelayExecWithGo struct {}

func (e grelayExecWithGo) exec(service GrelayService, func() (interface{}, error)) (interface{}, error) {
	// implementation
}

Change the grelayServiceImpl struct:

type grelayServiceImpl struct {
	// ...
	realExec                    grelayExec
	// ...
}

In NewGrelayService creates grelayExecWithGo:

func NewGrelayService(c GrelayConfig) GrelayService {
	var re grelayExec
	if c.withGo {
		re = grelayExecWithGo{}
	}
	g := &grelayServiceImpl{
		// ...
		realExec: re
	}
	// ...
}

In GrelayConfig include WithGo method and withGo attribute (put withGo = true as default in the future it will be false):

type GrelayConfig struct {
	// ...
	withGo bool
}

func NewGrelayConfig() GrelayConfig {
	return GrelayConfig{
		withGo:           true,
	}
}

func (c GrelayConfig) WithGo() GrelayConfig {
	c.withGo = true
	return c
}

move grelayServiceImpl.exec(f func() (interface{}, error)) to grelayExecWithGo.exec(service GrelayService, func() (interface{}, error)). In the final, we would like to have the grelayServiceImpl.exec(f func() (interface{}, error)) like that:

func (g *grelayServiceImpl) exec(f func() (interface{}, error)) (interface{}, error) {
	return g.realExec.exec(g, f)
}

Race condition test is failing (timeout error should appear)

Describe the bug
The test called: TestGrelayRequestExecWithOneItemInQueueReturningErrGrelayServiceTimedoutShouldReturnErrGrelayServiceTimedout is falling in branch refactoring when we try to run make test-race-condition. We need to solve this issue before merge this PR to main.

The current implementation works sometimes and other don't. We need to understand and fix this bug.

To Reproduce
Steps to reproduce the behavior:

  1. Run go test ./... -cpu=1,9 -race -count=50 -failfast -run GrelayRequestExecWithOneItemInQueueReturningErrGrelayServiceTimedoutShouldReturnErrGrelayServiceTimedout many times

Expected behavior
The test should pass without problems.

Screenshots
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.