1. Modify the default host to 172.17.0.1.
2. Add the add_task function to taskqueue client.
Signed-off-by: Cao Xueliang <caoxl78320(a)163.com>
---
lib/taskqueue_client.rb | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/taskqueue_client.rb b/lib/taskqueue_client.rb
index 91b72dc..2c22990 100644
--- a/lib/taskqueue_client.rb
+++ b/lib/taskqueue_client.rb
@@ -6,7 +6,7 @@ require 'rest-client'
# taskqueue client
class TaskQueueClient
- HOST = (ENV.key?('TASKQUEUE_HOST') ? ENV['TASKQUEUE_HOST'] : '127.0.0.1')
+ HOST = (ENV.key?('TASKQUEUE_HOST') ? ENV['TASKQUEUE_HOST'] : '172.17.0.1')
PORT = (ENV.key?('TASKQUEUE_PORT') ? ENV['TASKQUEUE_PORT'] : 3060).to_i
def initialize(host = HOST, port = PORT)
@host = host
@@ -20,4 +20,14 @@ class TaskQueueClient
url: url
)
end
+
+ def add_task(queue_path, json_data)
+ url = "http://#{@host}:#{@port}/add?queue=#{queue_path}"
+ RestClient::Request.execute(
+ method: :post,
+ url: url,
+ payload: json_data,
+ headers: { content_type: 'application/json' }
+ )
+ end
end
--
2.23.0