deepstreamHub
Last updated July 27, 2023
This article is a work in progress, or documents a feature that is not yet released to all users. This article is unlisted. Only those with the link can access it.
The deepstreamHub add-on is currently in beta.
Table of Contents
deepstreamHub provides a lightning-fast, real-time data store that connects browsers, smartphones, app backends, and the Internet of Things. It comes complete with real-time search, publish-subscribe, and request-response functionality.
deepstreamHub is accessible via an API with client libraries for Java, Node.js, Javascript, and Swift.
Provisioning the add-on
deepstreamHub can be attached to a Heroku application via the CLI:
A list of all plans available can be found here.
$ heroku addons:create deepstreamhub
-----> Adding deepstreamhub to sharp-mountain-4005... done, v18 (free)
After you provision deepstreamHub, the DEEPSTREAMHUB_APPURL
config var is available in your app’s configuration. You use this value to connect to the deepstreamHub API. You can inspect this value via the heroku config:get
command:
$ heroku config:get DEEPSTREAMHUB_APPURL
wss://154.deepstreamhub.com?apiKey=d72041da-ec81-430d-ad2a-2ff1607776ec
After you install deepstreamHub, your application should be configured to fully integrate with the add-on.
Local setup
Environment setup
After you provision the add-on, it’s necessary to locally replicate its config vars so your development environment can operate against the service.
Use the Heroku Local command-line tool to configure, run and manage process types specified in your app’s Procfile. Heroku Local reads configuration variables from a .env
file. To view all of your app’s config vars, type heroku config
. Use the following command for each value that you want to add to your .env
file:
$ heroku config:get DEEPSTREAMHUB_APPURL -s >> .env
Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env
file with: echo .env >> .gitignore
.
For more information, see the Heroku Local article.
Using with Node.js
To use deepstreamHub with Node.js, you install the deepstream.io-client-js
SDK and connect to your app’s DEEPSTREAMHUB_APPURL
.
Installation
Installing with npm
$ npm install deepstream.io-client-js --save
Installing with Yarn
$ yarn add deepstream.io-client-js
Importing the SDK
To import the SDK, add the following line to your app:
const deepstream = require( 'deepstream.io-client-js' );
Connecting to deepstreamHub
Connect to deepstreamHub at the URL specified in your DEEPSTREAMHUB_APPURL
config var:
const ds = deepstream( process.env.DEEPSTREAMHUB_APPURL );
Then, log in (in this example, no authentication has been configured, so no credentials are required in this call):
ds.login();
See the deepstreamHub documentation for an in-depth tutorial on using the Node.js SDK.
Using with Java
To use deepstreamHub with Java, add the following line to your build.gradle
file:
compile 'io.deepstream:deepstream.io-client-java:2.0.4'
In your application code, instantiate a client like so:
String deepstreamhub = System.getenv("DEEPSTREAMHUB_APPURL")
DeepstreamClient client = new DeepstreamClient(deepstreamhub);
Then, log in (in this example, no authentication has been configured, so no credentials are required in this call)
client.login();
See the deepstreamHub documentation for an in-depth tutorial on using deepstreamHub with Java.
Using with PHP
To use deepstreamHub with PHP, install the SDK with the following Composer command:
$ composer require deepstreamhub/deepstream.io-client-php`
The following example demonstrates emitting an event from PHP:
<?php
use Deepstreamhub\DeepstreamClient;
// Instantiates a client and emits an event
$client = new DeepstreamClient( $_ENV["DEEPSTREAMHUB_HTTP_APPURL"], array());
$client->emitEvent( 'news/sports', 'something about football is happening');
See the deepstreamHub documentation for an in-depth tutorial on using deepstreamHub with PHP.
Dashboard
The deepstreamHub dashboard allows you to view analytics, add or remove users, change authentication types, and much more.
You can access the dashboard via the CLI:
$ heroku addons:open deepstreamhub
Opening deepstreamhub for sharp-mountain-4005
or by visiting the Heroku Dashboard and selecting the application in question. Select deepstreamHub from the Add-ons menu.
Removing the add-on
You can remove deepstreamHub via the CLI:
This will destroy all associated data and cannot be undone!
$ heroku addons:destroy deepstreamhub
-----> Removing deepstreamhub from sharp-mountain-4005... done, v20 (free)
Support
All deepstreamHub support and runtime issues should be submitted via one of the Heroku Support channels. Any non-support related issues or product feedback is welcome at support@deepstreamhub.com, or via the support widget in the dashboard.