Class: Workling::Clients::MemcacheQueueClient
- Defined in:
- lib/workling/clients/memcache_queue_client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
the memcache connection object.
-
#queueserver_urls ⇒ Object
the url with which the memcache client expects to reach starling.
Instance Method Summary collapse
-
#close ⇒ Object
closes the memcache connection.
-
#connect ⇒ Object
the client attempts to connect to queueserver using the configuration options found in .
-
#request(key, value) ⇒ Object
implements the client job request and retrieval.
- #retrieve(key) ⇒ Object
Methods inherited from Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
delegates directly through to the memcache connection.
73 74 75 76 77 78 79 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 73 def method_missing(method, *args) begin self.connection.send(method, *args) rescue MemCache::MemCacheError => e raise Workling::WorklingConnectionError.new("#{e.class.to_s} - #{e.}") end end |
Instance Attribute Details
#connection ⇒ Object
the memcache connection object
24 25 26 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 24 def connection @connection end |
#queueserver_urls ⇒ Object
the url with which the memcache client expects to reach starling
21 22 23 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 21 def queueserver_urls @queueserver_urls end |
Instance Method Details
#close ⇒ Object
closes the memcache connection
43 44 45 46 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 43 def close self.connection.flush_all self.connection.reset end |
#connect ⇒ Object
the client attempts to connect to queueserver using the configuration options found in
Workling.config. this can be configured in config/workling.yml.
the initialization code will raise an exception if memcache-client cannot connect
to queueserver.
34 35 36 37 38 39 40 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 34 def connect @queueserver_urls = Workling.config[:listens_on].split(',').map { |url| url ? url.strip : url } = [@queueserver_urls, Workling.config[:memcache_options]].compact self.connection = MemcacheQueueClient.memcache_client_class.new(*) raise_unless_connected! end |
#request(key, value) ⇒ Object
implements the client job request and retrieval
49 50 51 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 49 def request(key, value) set(key, value) end |
#retrieve(key) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/workling/clients/memcache_queue_client.rb', line 53 def retrieve(key) begin get(key) rescue MemCache::MemCacheError => e # failed to enqueue, raise a workling error so that it propagates upwards raise Workling::WorklingError.new("#{e.class.to_s} - #{e.}") end end |