\Producers_MixpanelBaseProducer

Provides some base methods for use by a message Producer

Summary

Methods
Properties
Constants
__construct()
__destruct()
flush()
reset()
getQueue()
getToken()
enqueue()
enqueueAll()
_getEndpoint()
No public properties found
No constants found
_log()
_debug()
_getConsumer()
_persist()
$_options
$_token
$_max_queue_size
N/A
No private methods found
$_defaults
$_queue
$_consumer
$_consumers
N/A

Properties

$_options

$_options : array

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

Type

array

$_token

$_token : string

Type

string — a token associated to a Mixpanel project

$_max_queue_size

$_max_queue_size : integer

If the queue reaches this size we'll auto-flush to prevent out of memory errors

Type

integer

$_defaults

$_defaults : array

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

Type

array

$_queue

$_queue : array

Type

array — a queue to hold messages in memory before flushing in batches

$_consumers

$_consumers : array

Type

array — The list of available consumers

Methods

__construct()

__construct(  $token, array  $options = array()) 

Creates a new MixpanelBaseProducer, assings Mixpanel project token, registers custom Consumers, and instantiates the desired consumer

Parameters

$token
array $options

__destruct()

__destruct() 

Flush the queue when we destruct the client with retries

flush()

flush(integer  $desired_batch_size = 50) : boolean

Iterate the queue and write in batches using the instantiated Consumer Strategy

Parameters

integer $desired_batch_size

Returns

boolean —

whether or not the flush was successful

reset()

reset() 

Empties the queue without persisting any of the messages

getQueue()

getQueue() : array

Returns the in-memory queue

Returns

array

getToken()

getToken() : string

Returns the current Mixpanel project token

Returns

string

enqueue()

enqueue(array  $message = array()) 

Add an array representing a message to be sent to Mixpanel to a queue.

Parameters

array $message

enqueueAll()

enqueueAll(array  $messages = array()) 

Add an array representing a list of messages to be sent to Mixpanel to a queue.

Parameters

array $messages

_getEndpoint()

_getEndpoint() : string

Return the endpoint that should be used by a consumer that consumes messages produced by this producer.

Returns

string

_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

_persist()

_persist(  $message) : mixed

Given an array of messages, persist it with the instantiated Persistence Strategy

Parameters

$message

Returns

mixed