\ConsumerStrategies_CurlConsumer

Consumes messages and sends them to a host/endpoint using cURL

Summary

Methods
Properties
Constants
__construct()
getNumThreads()
persist()
getConnectTimeout()
getEndpoint()
getFork()
getHost()
getOptions()
getProtocol()
getTimeout()
No public properties found
No constants found
_encode()
_handleError()
_log()
_debug()
_execute()
_execute_forked()
$_options
$_host
$_endpoint
$_connect_timeout
$_timeout
$_protocol
$_fork
$_num_threads
N/A
No private methods found
$_defaults
N/A

Properties

$_options

$_options : array

An array of options to be used by the Mixpanel library.

Type

array

$_host

$_host : string

Type

string — the host to connect to (e.g. api.mixpanel.com)

$_endpoint

$_endpoint : string

Type

string — the host-relative endpoint to write to (e.g. /engage)

$_connect_timeout

$_connect_timeout : integer

Type

integer — connect_timeout The number of seconds to wait while trying to connect. Default is 5 seconds.

$_timeout

$_timeout : integer

Type

integer — timeout The maximum number of seconds to allow cURL call to execute. Default is 30 seconds.

$_protocol

$_protocol : string

Type

string — the protocol to use for the cURL connection

$_fork

$_fork : boolean|null

Type

boolean|null — true to fork the cURL process (using exec) or false to use PHP's cURL extension. false by default

$_num_threads

$_num_threads : integer

Type

integer — number of cURL requests to run in parallel. 1 by default

$_defaults

$_defaults : array

Default options that can be overridden via the $options constructor arg

Type

array

Methods

__construct()

__construct(array  $options) 

Creates a new CurlConsumer and assigns properties from the $options array

Parameters

array $options

Throws

\Exception

getNumThreads()

getNumThreads() : integer

Number of requests/batches that will be processed in parallel using curl_multi_exec.

Returns

integer

persist()

persist(array  $batch) : boolean

Write to the given host/endpoint using either a forked cURL process or using PHP's cURL extension

Parameters

array $batch

an array of messages to consume

Returns

boolean

getConnectTimeout()

getConnectTimeout() : integer

Returns

integer

getEndpoint()

getEndpoint() : string

Returns

string

getFork()

getFork() : boolean|null

Returns

boolean|null

getHost()

getHost() : string

Returns

string

getOptions()

getOptions() : array

Returns

array

getProtocol()

getProtocol() : string

Returns

string

getTimeout()

getTimeout() : integer

Returns

integer

_encode()

_encode(array  $params) : string

Encode an array to be persisted

Parameters

array $params

Returns

string

_handleError()

_handleError(  $code,   $msg) 

Handles errors that occur in a consumer

Parameters

$code
$msg

_log()

_log(  $msg) 

Log a message to PHP's error log

Parameters

$msg

_debug()

_debug() : boolean

Returns true if in debug mode, false if in production mode

Returns

boolean

_execute()

_execute(  $url,   $batch) : boolean

Write using the cURL php extension

Parameters

$url
$batch

Returns

boolean

_execute_forked()

_execute_forked(  $url,   $data) : boolean

Write using a forked cURL process

Parameters

$url
$data

Returns

boolean