Program the PubNub Data Stream Network and build microservices
PubNub Functions is a Function-as-a-Service platform that allows you to program the PubNub Data Stream Network and build your own microservices and webhooks, backed by the power of the PubNub DSN. PubNub Functions handles scaling, global deployment, redundancy and many other operations related work for you seamlessly.
PubNub Functions enables users to quickly and easily spin up microservices in the PubNub Data Stream Network (DSN) without the requirement of any additional supporting infrastructure.
By providing the ability to program the network, PubNub Functions simplifies deploying custom, realtime logic on a reliable, serverless architecture.
With PubNub Functions you can now program the network, executing a variety of operations against your data streams:
PubNub Functions provides HTTP endpoints that make building microservices and implementing Webhooks a breeze.
All PubNub Functions code is written in JavaScript, so there's no need to learn a new language. And once the code is written, it's easily deployed to the DSN globally as a microservice.
PubNub provides lifecycle management of your PubNub Functions (run, stop, update) through a simple and intuitive GUI, CLI, or REST APIs.
Get inspired by perusing the PubNub Functions catalog! PubNub is continually developing and maintaining the BLOCKS Catalog, a large collection of predefined and customizable PubNub Functions.
These predefined PubNub Functions provide ready-to-use code that can operate on your own data streams. PubNub is also continually adding partner-based catalog entries, integrating a wide variety of 3rd party APIs to the PubNub Functions ecosystem.
Catalog-based PubNub Functions are available to all PubNub Functions users at no additional cost – use them as-is, or modify them to fit a customized use case.
In this Quick Start, we will lead you through a step-by-step guide of how to create and deploy a Module in the PubNub Data Stream Network.
Just like other features of the Data Stream Network, PubNub Functions must be enabled on a per Keyset basis.
To enable a Keyset:
Voila! You can now create PubNub Functions for this Keyset.
Now that your Keyset is enabled for PubNub Functions, let's create a Module.
The name of a Module is a unique identifier scoped by the Keyset it's under. |
A Module is used as a container to group related Functions together. Since we just created this Module, it contains no Functions, so we'll create it now.
To create a Function, you can either hit the CREATE button on the left side or the GUIDE ME button and see some examples.
In the pop up window, configure your Function by:
PubNub Functions can be 1 of 4 types and the type of a Function determines when and how a Function will be triggered.
For more information on Function Types, please see Function Types.
Function Types involving Publish or Presence events are triggered by messages sent to one or several channels, and must always have at least one channel defined for it.
For a Function to execute against messages sent to a single channel, enter the channel name in the channel field.
If you adopt a naming convention with 2 levels of depth when specifying your channels, you can subscribe to channels by using wildcards.
For example, if you have several channels named foo.bar1, foo.bar2, foo.bar3, …, foo.barN, your Function can subscribe to all these channels by entering in the channel field: foo.*
For more information on wildcard subscribing see http://www.pubnub.com/knowledge-base/categories/wildcard-subscribe
And now the fun part starts. Coding! At this step, you can write your code logic in standard JavaScript. This code will be executed against every message received against the predefined channels.
Now that you are ready to start executing your Function, hit the Start Module button at the top right corner and your Module will be deployed around globe in under a second!