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, api_endpoint, stream_endpoint) ⇒ SignalFlowClient

Returns a new instance of SignalFlowClient.


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

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

Instance Method Details

#closeObject

Stop everything and close any open connections.


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

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 (Fixnum)
  • :stop (Fixnum)
  • :resolution (Fixnum)
  • :max_delay (Fixnum)
  • :persistent (Boolean)

Returns:


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

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 (Fixnum)
  • stop (Fixnum)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :max_delay (Fixnum)

Returns:


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

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:


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

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