Class: Imperium::Events

Inherits:
Client
  • Object
show all
Defined in:
lib/imperium/events.rb

Overview

A client for the Events API.

Constant Summary

Constants inherited from Client

Client::UNIVERSAL_API_OPTIONS

Instance Attribute Summary

Attributes inherited from Client

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

default_client, inherited, #initialize, #path_prefix, reset_default_client, reset_default_clients

Constructor Details

This class inherits a constructor from Imperium::Client

Class Method Details

.fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil) ⇒ Object

fire an event using the Client.default_client

See Also:



8
9
10
# File 'lib/imperium/events.rb', line 8

def self.fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil)
  default_client.fire(name, payload, dc: dc, node: node, service: service, tag: tag)
end

Instance Method Details

#fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil) ⇒ EventResponse

Fire the event

Examples:

Firing an event with a payload

response = Imperium::Events.fire('foo/bar', 'mypayload') # => EventResponse...

Parameters:

  • name (String)

    The name of the event

  • payload (String) (defaults to: nil)

    Additional data to send as payload of the event

  • dc (String) (defaults to: nil)

    Specify the datacenter to use for the request

  • node (String) (defaults to: nil)

    Specifies a regular expression to filter by node name

  • service (String) (defaults to: nil)

    Specifies a regular expression to filter by service name

  • tag (String) (defaults to: nil)

    Specifies a regular expression to filter by tag

Returns:

  • (EventResponse)


24
25
26
27
28
29
30
31
32
33
# File 'lib/imperium/events.rb', line 24

def fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil)
  query = {}
  query[:dc] = dc if dc
  query[:node] = node if node
  query[:service] = service if service
  query[:tag] = tag if tag
  response = @http_client.put(prefix_path("fire/#{name}"),
                              payload, query: query)
  EventFireResponse.new(response)
end