2017 © Pedro Peláez
 

library influxdb-php-async

Async PHP client for InfluxDB

image

stefanotorresi/influxdb-php-async

Async PHP client for InfluxDB

  • Monday, October 16, 2017
  • by stefanotorresi
  • Repository
  • 1 Watchers
  • 9 Stars
  • 538 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 2 % Grown

The README.md

InfluxDB PHP Async

An asyncronous client for InfluxDB, implemented via ReactPHP., (*1)

Build Status Latest Stable Version License, (*2)

Installation

Use Composer, (*3)

composer require stefanotorresi/influxdb-php-async, (*4)

Usage

Each client implementation exposes three main methods:, (*5)

interface AsyncClient
{
    public function query(string $query, array $params = []): Promise;
    public function write(string $payload, array $params = []): Promise;
    public function ping(): Promise;
    /* etc. */
}

The default implementation uses Buzz React and we'll use it throughout the rest of this document., (*6)

Here is a basic usage example where we first create a database, then write a line to it:, (*7)

$client = new ReactHttpClient();

$client
    ->query('CREATE DATABASE test')
    ->then(function($response) use ($client) {
        return $client->write('measure,tag="foo" value="bar"', ['db' => 'test']);
    })
    ->done()
;

$client->run();

Note that you need to run the ReactPHP event loop. If you don't inject your own, a default loop is composed by the client, and can be started via the run method., (*8)

This API assumes that you're familiar with ReactPHP promises., (*9)

Configuration

These are the default options:, (*10)

[
    'host'           => 'localhost',
    'port'           => 8086,
    'database'       => '',
    'username'       => '',
    'password'       => '',
    'socket_options' => [],
];

You can change them at instantion time, defaults will be merged with the one passed:, (*11)

$options = [ 
    'host' => 'influx-db.domain.tld', 
    'socket_options' => [
        'tls' => true,
    ],   
];

$client = new ReactHttpClient($options);

For details about the socket_options key, please refer to react/socket documentation., (*12)

Future developments / TO-DO list

  • An UDP client implemented with react/datagram.
  • A QueryBuilder, possibly identical to the one in the official influxdb-php client.
  • A set of response decoders that convert the JSON body from PSR-7 Responses to something more readily consumable.
  • Explore the possibility of merging this package into the official sdk.

License

This package is released under the MIT license., (*13)

The Versions

16/10 2017

dev-master

9999999-dev

Async PHP client for InfluxDB

  Sources   Download

MIT

The Requires

 

The Development Requires

16/10 2017

0.5.0

0.5.0.0

Async PHP client for InfluxDB

  Sources   Download

MIT

The Requires

 

The Development Requires

28/09 2017

0.4.0

0.4.0.0

Async PHP client for InfluxDB

  Sources   Download

MIT

The Requires

 

The Development Requires

07/09 2017

0.3.0

0.3.0.0

Async PHP client for InfluxDB

  Sources   Download

MIT

The Requires

 

The Development Requires