showclix/cube-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

showclix/cube-php

Composer 安装命令:

composer require showclix/cube-php

包简介

A PHP client for Cube

README 文档

README

Cube Client that supports communicating with a Cube collector and evaluator.

Usage

// Create a Client pointed at a local collector and evaluator
$client = \Cube\Client::createHttpClient(array(
    'collector' => array(
        'host' => 'localhost',
        'port' => 1080,
    ),
    'evaluator' => array(
        'host' => 'localhost',
        'port' => 1081,
    ),
    'secure' => true,
));

$res = $client->metricGet(array(
    'expression' => 'sum(cube_request)',
    'step' => \Cube\Client::INT_ONE_MINUTE,
    'limit' => 100,
));

echo "There were {$res[0]['value']} hits during {$res[0]['time']}";

Install

Via composer

composer.phar install showclix/cube-php

API

\Cube\Client

[static] createHttpClient(array $conf)

param array $conf

Configuration array. For example:

array(
    'collector' => array(
        'host' => 'localhost',
        'port' => 1080,
    ),
    'evaluator' => array(
        'host' => 'localhost',
        'port' => 1081,
    ),
    'secure' => true,
)

return \Cube\Client

eventPut(array $event)

param array $event

The event to push to cube. Requires type, time and data options.

array(
    'type' => 'example',
    'time' => time(),
    'data' => array(
        'key' => 'value',
    ),
)

returns array response from Cube

eventGet(array $query)

param array $query

returns array

EXAMPLE

$query = array(
    'expression' => 'request.eq(path, "search")',   // cube expression
    'limit' => 10,                                  // limit (optional)
);
$client->metricGet($query);

metricGet(array $query)

param array $query Metric query to send to cube evaluator

returns array

EXAMPLE

$query = array(
    'expression' => 'sum(type_name)',   // cube expression
    'start' => strtotime('-1 day'),     // start time (optional)
    'stop' => time(),                   // end time (optional)
    'limit' => 10,                      // limit (optional)
    'step' => Client::INT_ONE_MINUTE,   // time grouping interval
);
$res = $client->metricGet($query);
echo "There were {$res[0]['value']} during {$res[0]['time']}";

typesGet()

returns array of all types currently in cube

Todo

  • Implement \Cube\Connection\WebSocketConnection
  • Implement \Cube\Connection\UdpConnection
  • Add Travis CI Integaration complete with hooks to setup and install Cube/Mongo

统计信息

  • 总下载量: 4.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 31
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-02-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固