Giter Site home page Giter Site logo

Not clear how to implement client about gruf HOT 3 CLOSED

quinn avatar quinn commented on July 24, 2024
Not clear how to implement client

from gruf.

Comments (3)

quinn avatar quinn commented on July 24, 2024

like, this code example is completely useless:

require 'gruf'

id = args[:id].to_i.presence || 1

begin
  client = ::Gruf::Client.new(service: ::Demo::ThingService)
  response = client.call(:GetMyThing, id: id)
  puts response.message.inspect
rescue Gruf::Client::Error => e
  puts e.error.inspect
end

Does that go in every place in the code, immediately before calling the client? I highly doubt it. You're assigning the client to a local var. Does this mean that every instance of a client is used for only one RPC call? Its very misleading / useless code example.

from gruf.

splittingred avatar splittingred commented on July 24, 2024

Hi @quinn - apologies for the lack of docs! Yes, we probably can add more here, but generally gruf follows the same concepts and behaviors as the Ruby gRPC client, which is where you instantiate a client object paired with a service stub, and then call actions on it.

You can make separate calls by just calling the call method on the client multiple times, or call different methods. Similarly, you can use dependency injection to store an instance of the client app-wide, if you don't want to instantiate it in a class. Gruf is purposely unopinionated on this, to allow for flexibility in upstream systems.

from gruf.

splittingred avatar splittingred commented on July 24, 2024

Hi @quinn - I've added a wiki to the gruf repo: https://github.com/bigcommerce/gruf/wiki

You can find information about client creation here: https://github.com/bigcommerce/gruf/wiki/Client%3A-Installation and following.

This should have plenty of detail to get you started. I'll keep augmenting this further in the next few weeks. Thanks for the feedback!

from gruf.

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.