AbstractConsumer.php
2 years ago
CurlConsumer.php
2 years ago
FileConsumer.php
2 years ago
SocketConsumer.php
2 years ago
index.php
2 years ago
AbstractConsumer.php
30 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | require_once(dirname(__FILE__) . "/../Base/MixpanelBase.php"); |
| 4 | abstract class ConsumerStrategies_AbstractConsumer extends Base_MixpanelBase { |
| 5 | function __construct($options = array()) { |
| 6 | parent::__construct($options); |
| 7 | if ($this->_debug()) { |
| 8 | $this->_log("Instantiated new Consumer"); |
| 9 | } |
| 10 | } |
| 11 | protected function _encode($params) { |
| 12 | return base64_encode(json_encode($params)); |
| 13 | } |
| 14 | protected function _handleError($code, $msg) { |
| 15 | if (isset($this->_options['error_callback'])) { |
| 16 | $handler = $this->_options['error_callback']; |
| 17 | call_user_func($handler, $code, $msg); |
| 18 | } |
| 19 | if ($this->_debug()) { |
| 20 | $arr = debug_backtrace(); |
| 21 | $class = get_class($arr[0]['object']); |
| 22 | $line = $arr[0]['line']; |
| 23 | error_log ( "[ $class - line $line ] : " . print_r($msg, true) ); |
| 24 | } |
| 25 | } |
| 26 | public function getNumThreads() { |
| 27 | return 1; |
| 28 | } |
| 29 | abstract function persist($batch); |
| 30 | } |