Socket
Book a DemoInstallSign in
Socket

pachube-stream

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pachube-stream

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

== PachubeStream

PachubeStream gives you an API for the Pachube TCP Stream using EventMachine

http://api.pachube.com/v2/beta/#tcp-socket-and-websocket-connections

== Quickstart

require "pachube-stream" connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"])

Look at the examples directory for exactly that!

== Connection Methods

The methods on the connection are what Pachube look for when making a request; this in-turn will generate the correct method value in the 'http json'

=== Example connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.subscribe("/feeds/504")

Results In the following JSON request

{ "method" : "subscribe", "resource" : "/feeds/504", "headers" : { "X-PachubeApiKey" : "API_KEY" }, "token" : "subscribe" }

=== Subscribe

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.subscribe("/feeds/504") request.on_datastream do |response| puts response end

=== Unsubscribe

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.unsubscribe("/feeds/504") request.on_compelete do |response| puts response end

=== Get

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.get("/feeds/504") request.on_get do |response| puts response end

=== Put

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.put("/feeds/504") request.on_complete do |response| puts response end

=== Delete

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.delete("/feeds/504") request.on_complete do |response| puts response end

=== Post

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.post("/feeds/504") request.on_complete do |response| puts response end

The way we make a request is to send json in the format of a HTTP request; you only have to give extra options when you want to provide your own headers, params and body etc;

Therefore when using the connection Methods

When can create this 'http json request' with PachubeStream::HttpRequest passing in a hash

connection = PachubeStream::Connection.connect(:api_key => ENV["PACHUBE_API_KEY"]) request = connection.put("/feeds/504", PachubeStream::HttpRequest.new(:body => {}, :params => {}, :headers => {}))

request.on_complete do |response| puts response end

== Defaults:

When creating a connection you can specify the host and port these have defaults

host                       # => beta.pachube.com
port                       # => 8081

== Respect

Respect goes out to the twitter-stream Gem as one took some concepts form that; nice!

FAQs

Package last updated on 24 Apr 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.