Code Monkey home page Code Monkey logo

Comments (6)

nishanttotla avatar nishanttotla commented on July 28, 2024

cc @dongluochen @calavera

from engine-api.

duglin avatar duglin commented on July 28, 2024

@nishanttotla can you elaborate on how this nopclient is used?

from engine-api.

nishanttotla avatar nishanttotla commented on July 28, 2024

@duglin it's used here: https://github.com/docker/swarm/blob/master/cluster/engine.go

The primary purpose is to void every action if an Engine goes down in the cluster. It avoids heavy locking around engine/list structs and pending operations. Without this, Swarm performance can degrade.

from engine-api.

calavera avatar calavera commented on July 28, 2024

I'm pretty sure we don't need that. You can probably achieve the same behavior with a custom Transport that always returns a client.

Steps:

1- Implement the RoundTripper interface:

type NopTrip struct {}
func (NopTrip) RoundTrip(*Request) (*Response, error) {
  return nil, errors.New("nop")
}

2- Create a new HTTPClient using that transport:

client := http.Client{
  Transport: NotTrip{},
}

3- Create an API client with this new client:

api, _ := client.NewClient("...", "", client, ...)

🎉

If this doesn't work, we should consider change the code enough to make it work. This approach is way more scalable than the nopclient because we don't have to add new methods to it every time something is added to the client.

from engine-api.

calavera avatar calavera commented on July 28, 2024

As a second note, Swarm should consider using the Circuit Breaker pattern rather than this hack:

http://martinfowler.com/bliki/CircuitBreaker.html

An implementation in Go: https://github.com/rubyist/circuitbreaker

from engine-api.

nishanttotla avatar nishanttotla commented on July 28, 2024

@calavera thanks, that sounds like a great suggestion! I'll close this issue for now, and I think we can consider moving away from the nopclient after the 1.2 release next month.

from engine-api.

Related Issues (20)

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.