Giter VIP home page Giter VIP logo

mesg-pusher's Introduction

mesg-pusher deprecated License Latest Release Build Status mesg-cli semantic-release Codacy Badge Dependencies

⚠️ Please note that this project is deprecated and no longer maintained.

MESG Service for Pusher ID: com.mesg.pusher

MESG Pusher

Contents

Installation

MESG SDK

This service requires MESG SDK to be installed first.

You can install MESG SDK by running the following command or follow the installation guide.

npm install -g mesg-cli

Deploy the Service

To deploy this service, go to this service page on the MESG Marketplace and click the button "get/buy this service".

Features

Currently able to use Pusher channels, channel, trigger and triggerBatch features from MESG.

Use case

MESG Applications on different servers communicating together over Pusher notifications.

Example

  1. on MESG Application on a server A : use this MESG Service to send notifications over Pusher.

  2. on MESG Application on a server B : listen to the notifications emitted by MESG Application on a server A over Pusher.

How to listen in a MESG Application

Install MESG and Pusher dependencies :

yarn add mesg-js pusher-js

Create a socket connection to listen and react to Pusher notifications :

// in a MESG Application
const { application } = require('mesg-js')
const mesg = application()
const Pusher = require('pusher-js')
const pusher = new Pusher('PUSHER_APP_KEY', { cluster: 'PUSHER_CLUSTER', forceTLS: true }) // replace with your credentials
const INSTANCE_HASH = await mesg.resolve('com.mesg.pusher')
const CHANNEL = 'some-channel'
const EVENT = 'some-event'
const CREDENTIALS = { appId: 'PUSHER_APP_ID', key: 'PUSHER_APP_KEY', secret: 'PUSHER_APP_SECRET' } // replace with your credentials
// subscribe to Pusher channel
const channel = pusher.subscribe(CHANNEL)
// on Pusher notification received
channel.bind(EVENT, data => {
  // example : launch MESG service trigger task
  mesg.executeTask({
    instanceHash: INSTANCE_HASH,
    taskKey: 'trigger',
    inputs: mesg.encodeData({ ...CREDENTIALS, channel: CHANNEL, event: EVENT, ...data })
  })
})

Environment variables

Instead of providing Pusher credentials or options on each request, these can be provided via command line arguments or .env file, as shown below in Integration tests.

As usual, user inputs always takes precedence on defined environment variables.

Name Enviroment Variable
appId PUSHER_APP_ID
cluster PUSHER_CLUSTER
useTLS PUSHER_USE_TLS
host PUSHER_HOST
keepAlive PUSHER_KEEP_ALIVE
key PUSHER_APP_KEY
port PUSHER_PORT
proxy PUSHER_PROXY
secret PUSHER_APP_SECRET
timeout PUSHER_TIMEOUT

Integration tests

In order to launch them locally you will have to pass the environment variables along with your command, like so :

  • via command line arguments :
    export PUSHER_APP_ID=... && export PUSHER_APP_KEY=... && export PUSHER_APP_SECRET=... && export PUSHER_CLUSTER=... && export MESG_ACCOUNT=... && export MESG_PASSPHRASE=... && yarn test
  • via .env file :
    • file
      export PUSHER_APP_ID=...
      export PUSHER_APP_KEY=...
      export PUSHER_APP_SECRET=...
      export PUSHER_CLUSTER=...
      export MESG_ACCOUNT=...
      export MESG_PASSPHRASE=...
      
    • command
      source .env && yarn test

Definitions

Tasks

trigger

Task key: trigger

triggers an event on one or more channels

Inputs
Name Key Type Description
appId appId String optional Pusher application ID
key key String optional Pusher application key
secret secret String optional Pusher application secret key
useTLS useTLS Boolean optional whether to encrypt notification, defaults to false
cluster cluster String optional if `host` is present, it will override the `cluster` option
host host String optional whether to use a different host, defaults to api.pusherapp.com
port port Number optional whether to use a different port, defaults to 80 for unuseTLS and 443 for useTLS
proxy proxy String optional URL to proxy the requests through
timeout timeout Number optional timeout for all requests in milliseconds
keepAlive keepAlive Boolean optional enables keep-alive, defaults to false
name name String event name
data data Object event data (maximum 10Kb)
channels channels Object optional array of one or more channel names - limited to 100 channels
channel channel String optional channel name if publishing to a single channel (can be used instead of channels)
socket_id socket_id Object optional excludes the event from being sent to a specific connection
Outputs
Name Key Type Description
message message String a dummy 'sent' message

triggerBatch

Task key: triggerBatch

triggers multiple events in a single call (up to 10 per call on the multi-tenant clusters)

Inputs
Name Key Type Description
appId appId String optional Pusher application ID
key key String optional Pusher application key
secret secret String optional Pusher application secret key
useTLS useTLS Boolean optional whether to encrypt notification, defaults to false
cluster cluster String optional if `host` is present, it will override the `cluster` option
host host String optional whether to use a different host, defaults to api.pusherapp.com
port port Number optional whether to use a different port, defaults to 80 for unuseTLS and 443 for useTLS
proxy proxy String optional URL to proxy the requests through
timeout timeout Number optional timeout for all requests in milliseconds
keepAlive keepAlive Boolean optional enables keep-alive, defaults to false
batch batch Object array of events (maximum 10)
Outputs
Name Key Type Description
message message String a dummy 'sent' message

channels

Task key: channels

get the list of the channel within an application that have active subscriptions (also referred to as being occupied)

Inputs
Name Key Type Description
appId appId String optional Pusher application ID
key key String optional Pusher application key
secret secret String optional Pusher application secret key
useTLS useTLS Boolean optional whether to encrypt notification, defaults to false
cluster cluster String optional if `host` is present, it will override the `cluster` option
host host String optional whether to use a different host, defaults to api.pusherapp.com
port port Number optional whether to use a different port, defaults to 80 for unuseTLS and 443 for useTLS
proxy proxy String optional URL to proxy the requests through
timeout timeout Number optional timeout for all requests in milliseconds
keepAlive keepAlive Boolean optional enables keep-alive, defaults to false
params params Object optional additional parameters to be sent as query string parameters (see HTTP API Reference)
Outputs
Name Key Type Description
channels channels String array of channel names

channel

Task key: channel

fetch one or some attributes for a given channel

Inputs
Name Key Type Description
appId appId String optional Pusher application ID
key key String optional Pusher application key
secret secret String optional Pusher application secret key
useTLS useTLS Boolean optional whether to encrypt notification, defaults to false
cluster cluster String optional if `host` is present, it will override the `cluster` option
host host String optional whether to use a different host, defaults to api.pusherapp.com
port port Number optional whether to use a different port, defaults to 80 for unuseTLS and 443 for useTLS
proxy proxy String optional URL to proxy the requests through
timeout timeout Number optional timeout for all requests in milliseconds
keepAlive keepAlive Boolean optional enables keep-alive, defaults to false
params params Object optional additional parameters to be sent as query string parameters (see HTTP API Reference)
Outputs
Name Key Type Description
occupied occupied Boolean whether the channel currently has active subscriptions
user_count user_count Number optional number of distinct users currently subscribed to this channel (a single user may be subscribed many times, but will only count as one)
subscription_count subscription_count Number optional number of connections currently subscribed to this channel (not available by default, has to be enabled in dashboard)

mesg-pusher's People

Contributors

renovate-bot avatar roms1383 avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar

mesg-pusher's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.