API Documentation

# \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

File
  ConsumerStrategies/CurlConsumer.php
Package
  Default
Class hierarchy
  \Base_MixpanelBase
  \ConsumerStrategies_AbstractConsumer
  \ConsumerStrategies_CurlConsumer

## Tags

None found

## Properties

### $_options

    $_options : array

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

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### $_host

    $_host : string

#### Type

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

#

## Tags

None found

### $_endpoint

    $_endpoint : string

#### Type

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

#

## Tags

None found

### $_connect_timeout

    $_connect_timeout : integer

#### Type

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

#

## Tags

None found

### $_timeout

    $_timeout : integer

#### Type

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

#

## Tags

None found

### $_protocol

    $_protocol : string

#### Type

string — the protocol to use for the cURL connection

#

## Tags

None found

### $_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

#

## Tags

None found

### $_num_threads

    $_num_threads : integer

#### Type

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

#

## Tags

None found

### $_defaults

    $_defaults : array

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

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

## Methods

### __construct()

    __construct(array  $options)

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

#### Parameters

array | $options |

#### Throws

\Exception

#

## Tags

None found

### getNumThreads()

    getNumThreads() : integer

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

#### Returns

integer

#

## Tags

None found

### 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

#

## Tags

None found

### getConnectTimeout()

    getConnectTimeout() : integer

#### Returns

integer

#

## Tags

None found

### getEndpoint()

    getEndpoint() : string

#### Returns

string

#

## Tags

None found

### getFork()

    getFork() : boolean|null

#### Returns

boolean|null

#

## Tags

None found

### getHost()

    getHost() : string

#### Returns

string

#

## Tags

None found

### getOptions()

    getOptions() : array

#### Returns

array

#

## Tags

None found

### getProtocol()

    getProtocol() : string

#### Returns

string

#

## Tags

None found

### getTimeout()

    getTimeout() : integer

#### Returns

integer

#

## Tags

None found

### _encode()

    _encode(array  $params) : string

Encode an array to be persisted

#### Parameters

array | $params |

#### Returns

string

#

Inherited from
  \ConsumerStrategies_AbstractConsumer

## Tags

None found

### _handleError()

    _handleError(  $code,   $msg)

Handles errors that occur in a consumer

#### Parameters

| $code |
| $msg |

#

Inherited from
  \ConsumerStrategies_AbstractConsumer

## Tags

None found

### _log()

    _log(  $msg)

Log a message to PHP's error log

#### Parameters

| $msg |

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### _debug()

    _debug() : boolean

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

#### Returns

boolean

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### _execute()

    _execute(  $url,   $batch) : boolean

Write using the cURL php extension

#### Parameters

| $url |
| $batch |

#### Returns

boolean

#

## Tags

None found

### _execute_forked()

    _execute_forked(  $url,   $data) : boolean

Write using a forked cURL process

#### Parameters

| $url |
| $data |

#### Returns

boolean

#

## Tags

None found

### CurlConsumer.php