class Gitrob::Github::ClientManager
Constants
- USER_AGENT
Attributes
clients[R]
Public Class Methods
new(config)
click to toggle source
# File lib/gitrob/github/client_manager.rb, line 10 def initialize(config) @config = config @mutex = Mutex.new @clients = [] config[:access_tokens].each do |token| clients << create_client(token) end end
Public Instance Methods
remove(client)
click to toggle source
# File lib/gitrob/github/client_manager.rb, line 26 def remove(client) @mutex.synchronize do clients.delete(client) end end
sample()
click to toggle source
# File lib/gitrob/github/client_manager.rb, line 19 def sample @mutex.synchronize do fail NoClientsError if clients.count.zero? clients.sample end end
Private Instance Methods
create_client(access_token)
click to toggle source
# File lib/gitrob/github/client_manager.rb, line 34 def create_client(access_token) ::Github.new( :oauth_token => access_token, :endpoint => @config[:endpoint], :site => @config[:site], :ssl => @config[:ssl], :user_agent => USER_AGENT, :auto_pagination => true ) end