Ruby SDK for Conduit

Installation

Add this line to your application's Gemfile:

gem 'conduit-sdk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install conduit-sdk

Usage

Create a client

To create a client you will need an administrative access key and key name. These can be generated from the conduit CLI on the server.

    Conduit::Client.new(hostAddress, keyName, keySecret)

Register a mailbox

    client = Conduit::Client.new(hostAddress, keyName, keySecret)
    client.register("my.mailbox.name")

This will register a new mailbox with the server, it will raise Conduit::APIError on failure.

Deregister a mailbox

    client = Conduit::Client.new(hostAddress, keyName, keySecret)
    client.deregister("my.mailbox.name")

This will delete a mailbox and purge its messages, it will raise Conduit::APIError on failure.

Getting system statistics

The system_stats method will return a number of metrics.

    client = Conduit::Client.new(hostAddress, keyName, keySecret)
    stats = client.system.stats
    puts stats[:field]

Fields

  • totalMailboxes - The total number of mailboxes registered in the system.
  • messageCount - The total number of messages that have passed through the system.
  • pendingMessages - The current number of messages waiting to be delivered.
  • connectedClients - The current number of clients that are connected to the server.
  • dbVersion - The server database version.
  • threads - The number of active threads the server is using.
  • cpuCount - The number of CPUs available to the server.
  • memory - The total allocated memory the server is currently using.
  • filesCount - The total number of script assets stored on the server.
  • filesSize - The size on disk of all script assets the server is holding.

Getting client statistics

The system_stats method will return a number of metrics.

    client = Conduit::Client.new(hostAddress, keyName, keySecret)
    stats = client.client_stats.clients.each do |client|
        puts client[:field]
    end

Fields

  • version - The client's last reported Conduit version.
  • online - True if the client is currently connected.
  • mailbox - The client's mailbox name.
  • lastSeenAt - A date/time string when the client last checked for messages.
  • host - The IP address of the client.

Listing deployments

    client = Conduit::Client.new(hostAddress, keyName, keySecret)
    client.list_deployments(_options_).deployments.each do |d|
        puts d[:field]
    end

Options

  • deploymentId - The name of a specific deployment. If specified the response will contain a :responses array which will contain information on the client responses to the deployment.
  • nameSearch - A glob pattern for searching deployment names (ex: "Upgrade*").
  • keySearch - A glob pattern for searching for deployments based on the keyname that deployed them (ex: ops.*).
  • count - The number of deployments to return.

Fields

  • name - The name of the deployment
  • createdAt A date string representing the creation time of the deployment.
  • pendignMessages - The number of messages that have not been picked up.
  • totalMessages - The total number of messages deployed.
  • responseCount - The number of responses received
  • responses - An array of hashses for the client responses to the deployments. Each has has the follwoing keys: Mailbox, Response, RespondedAt, and IsError. This value is only present if a specific deploymentId was specifeid.
  • deployedBy - The access key name used to create the deployment.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/conduit-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request