Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ messenger_dialog = Dialog.new(api_token: ENV['DIALOG_API_TOKEN'], bot_id: 'messe
kik_dialog = Dialog.new(api_token: ENV['DIALOG_API_TOKEN'], bot_id: 'kik_bot_id')
```

## Performance

This library if built to support high performance environments. It is safe to use dialog-ruby on a web server serving hundreds of requests per second.

Every time `track` is called an asynchronous HTTP request is sent, allowing non-blocking usage and fast response latencies.

## Development

Run all tests:
Expand Down
1 change: 1 addition & 0 deletions dialog-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ Gem::Specification.new do |s|
s.test_files = s.files.grep(%r{^(spec)/})

s.add_dependency 'http', '~> 2.0'
s.add_dependency 'concurrent-ruby'
end
2 changes: 1 addition & 1 deletion lib/dialog-api/api/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def track(payload)
}
}

post("b/#{bot_id}/track", body: body)
async.post("b/#{bot_id}/track", body: body)
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/dialog-api/client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent'

require 'dialog-api/request'
require 'dialog-api/api/conversation'
require 'dialog-api/api/interlocutor'
Expand All @@ -6,6 +8,8 @@

module Dialog
class Client
include Concurrent::Async

include Dialog::Request
include Dialog::API::Conversation
include Dialog::API::Interlocutor
Expand All @@ -16,6 +20,8 @@ class Client

# @param options [Hash]
def initialize(options = {})
super() # Important for concurrent ruby

options = Dialog.options.merge(options)
Configuration::VALID_OPTIONS_KEYS.each do |key|
send("#{key}=", options[key])
Expand Down