Class: SignalFlowClient

Inherits:
Object
  • Object
show all
Defined in:
lib/signalfx/signalflow/client.rb

Overview

A SignalFlow client that uses the WebSockets interface.

See developers.signalfx.com/v2/reference#signalflowconnect for low-level API details and information on the SignalFlow language.

See https://github.com/signalfx/signalfx-ruby/blob/master/examples/signalflow.rb for an example script that uses the client.

The messages passed into the ‘computation.each_message*` blocks will be decoded forms of what is described in our API reference for SignalFlow. Hash keys will be symbols instead of strings.

Instance Method Summary collapse

Constructor Details

#initialize(api_token, stream_endpoint) ⇒ SignalFlowClient

Returns a new instance of SignalFlowClient.



22
23
24
# File 'lib/signalfx/signalflow/client.rb', line 22

def initialize(api_token, stream_endpoint)
  @transport = SignalFlowWebsocketTransport.new(api_token, stream_endpoint)
end

Instance Method Details

#closeObject

Stop everything and close any open connections.



71
72
73
# File 'lib/signalfx/signalflow/client.rb', line 71

def close
  @transport.close
end

#execute(program, **options) ⇒ Computation

Start a computation and attach to its output. If using WebSockets (the default), the channel name is handled internally so you do not need to supply it.

See developers.signalfx.com/reference#section-execute-a-computation

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :start (Integer)
  • :stop (Integer)
  • :resolution (Integer)
  • :max_delay (Integer)
  • :persistent (Boolean)
  • :immediate (Boolean)

Returns:



40
41
42
# File 'lib/signalfx/signalflow/client.rb', line 40

def execute(program, **options)
  @transport.execute(program, **options)
end

#preflight(program, start, stop, **options) ⇒ Computation

Start and attach to a computation that tells how many times a detector would have fired in a time range between ‘start` and `stop`.

See developers.signalfx.com/v2/reference#signalflowpreflight

Parameters:

  • start (Integer)
  • stop (Integer)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :max_delay (Integer)

Returns:



54
55
56
# File 'lib/signalfx/signalflow/client.rb', line 54

def preflight(program, start, stop, **options)
  @transport.preflight(program, start, stop, **options)
end

#start(program, **options) ⇒ Computation

Start a computation without attaching to it

The ‘publish()` call in the program must specify a `metric` to publish the output to since you cannot currently attach to the output.

Optional parameters are the same as #execute.

Returns:



66
67
68
# File 'lib/signalfx/signalflow/client.rb', line 66

def start(program, **options)
  @transport.start(program, **options)
end