Skip to content

Loading…

Made request id available to the client #45

Closed
wants to merge 2 commits into from

2 participants

@oholiab

No description provided.

oholiab added some commits
@oholiab oholiab Made request id an attribute reader for Client
This is to enable the reading of the request id in a standard RPC
request so that replies can be matched with their requests if they are
performed in a "detached" manner.

When ::Client is initialized in ::RPC::Client, it is made an
attr_reader, so in an instance of ::RPC::Client

mc = rpcclient(rpc)
mc.client.reqid                     #=> nil

mc.action()
mc.client.reqid                     #=> returns request id.
cf47eef
@oholiab oholiab Moved assignment of @reqid in Class to senreq
Ensures that code bypassing req and running sendreq directly still sets
the reqid attribute reader and thus still has access to the request id.
dc602a3
@ripienaar ripienaar closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2012
  1. @oholiab

    Made request id an attribute reader for Client

    oholiab committed
    This is to enable the reading of the request id in a standard RPC
    request so that replies can be matched with their requests if they are
    performed in a "detached" manner.
    
    When ::Client is initialized in ::RPC::Client, it is made an
    attr_reader, so in an instance of ::RPC::Client
    
    mc = rpcclient(rpc)
    mc.client.reqid                     #=> nil
    
    mc.action()
    mc.client.reqid                     #=> returns request id.
  2. @oholiab

    Moved assignment of @reqid in Class to senreq

    oholiab committed
    Ensures that code bypassing req and running sendreq directly still sets
    the reqid attribute reader and thus still has access to the request id.
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/mcollective/client.rb
View
4 lib/mcollective/client.rb
@@ -2,6 +2,7 @@ module MCollective
# Helpers for writing clients that can talk to agents, do discovery and so forth
class Client
attr_accessor :options, :stats, :discoverer
+ attr_reader :reqid
def initialize(configfile)
@config = Config.instance
@@ -11,6 +12,7 @@ def initialize(configfile)
@security = PluginManager["security_plugin"]
@security.initiated_by = :client
+ @reqid = nil
@options = nil
@subscriptions = {}
@@ -54,7 +56,7 @@ def sendreq(msg, agent, filter = {})
request.publish
- request.requestid
+ @reqid = request.requestid
end
def subscribe(agent, type)
Something went wrong with that request. Please try again.