Class: Gaurun::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gaurun-ruby/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint: 'http://localhost:1056') ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/gaurun-ruby/client.rb', line 5

def initialize(endpoint: 'http://localhost:1056')
  @endpoint = endpoint_from_env || endpoint
end

Instance Method Details

#config_pushers(max) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/gaurun-ruby/client.rb', line 28

def config_pushers(max)
  req = generate_request(
    path: "/config/pushers?max=#{max}",
    method: 'put'
  )
  do_request(req)
end

#parallel_push(notifications) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gaurun-ruby/client.rb', line 14

def parallel_push(notifications)
  hydra = Typhoeus::Hydra.new
  reqs = notifications.map do |notification|
    req = generate_push_request(notification)
    hydra.queue(req)
    req
  end
  hydra.run

  reqs.map do |req|
    Gaurun::Response.new(req.response)
  end
end

#push(notification) ⇒ Object



9
10
11
12
# File 'lib/gaurun-ruby/client.rb', line 9

def push(notification)
  req = generate_push_request(notification)
  do_request(req)
end

#stat_appObject



41
42
43
44
# File 'lib/gaurun-ruby/client.rb', line 41

def stat_app
  req = generate_request(path: '/stat/app', method: 'get')
  do_request(req)
end

#stat_goObject



36
37
38
39
# File 'lib/gaurun-ruby/client.rb', line 36

def stat_go
  req = generate_request(path: '/stat/go', method: 'get')
  do_request(req)
end