Skip to content

bpulse/bpulse-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bpulse/bpulse-sdk-php

This is a conector between any PHP based application subscribed to BPULSE Service and the PULSES COLLECTOR REST SERVICE. This README explains how to integrate the conector with the target client application, configuration parameters and how to use it.

REQUIREMENTS

  • protocol buffers compiler library (libprotoc)

INSTALLING

The recommended way to install this connector is through Composer.

Add to your composer.json

"require": {
	"bpulse/bpulse-sdk-php": "dev-master",
	"bpulse/bpulse-protobuf-php": "dev-master"
}

run composer install

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

STARTING YOUR APPLICATION

the first thing you should to do is generate the PHP classes you'll need to send Pulses. To do this, you need to run the following command on bpulse-protobuf-php repository folder located in vendor/bpulse

make build

The connector needs some configuration properties that indicate the client where to connect so you must provide a properties file, so to do that, append this config.json to the main folder of your application

{
	"host": "http://[bpulse.host]/app.collector/collector/pulses:port",
	"username": "[email protected]",
	"password": "collector123"
}

USAGE

The starting point are the BPulse\Entity classes and Bpulse\Rest\Connector class. Then use a combination of methods to build the pulses you want to send according to the Pulse Definition made in BPULSE, for example:

//Add the namespaces

use Bpulse\Entity\Pulse;
use Bpulse\Entity\PulsesRQ;
use Bpulse\Entity\Value;
use Bpulse\Rest\Connector;


//Generate Pulses

$pulses= new PulsesRQ();
$pulses->setVersion("1.0");
$pulse= new Pulse();

$pulse->setInstanceId("1");
$pulse->setTypeId("bpulse_bpulse_processedPulses");
$milliseconds = round(microtime(true) * 1000);
$pulse->setTime($milliseconds);

$value= new Value;
$value->setName("nErrors");
$value->addValues("1");
$pulse->addValues($value);

$value= new Value;
$value->setName("nPulses");
$value->addValues("19");
$pulse->addValues($value);


$value= new Value;
$value->setName("rsInstance");
$value->addValues("Angel");
$pulse->addValues($value);

$value= new Value;
$value->setName("clientId");
$value->addValues("demo");
$pulse->addValues($value);

$value= new Value;
$value->setName("rsTime");
$value->addValues("1200");
$pulse->addValues($value);


$pulses->addPulse($pulse);                         

$connector= new Connector;


$code=$connector->send($pulses); //This return the http response status code

License

The Bpulse SDK PHP is licensed under the Apache License 2.0. Details can be found in the LICENSE file.

About

Bpulse SDK PHP or BPulse PHP Client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages