PHP Class Scalr\LogCollector\Writers\AbstractWriter

Author: Constantine Karnacevych ([email protected])
Afficher le fichier Open project: scalr/scalr Class Usage Examples

Protected Properties

Свойство Type Description
$host string Either path for local FS or hostname for remote connection
$port integer Port to use if connected to a remote host
$scheme string Protocol to use
$timeout integer How long to wait for reply from the remote end (seconds)

Méthodes publiques

Méthode Description
__construct ( string $proto = "http", string $path = "localhost", integer $port = 8888, integer $timeout = 1 ) Constructor. Instantiates the writer.
formatMessage ( array $data ) : string Converts the data into backend acceptable format
send ( array $data ) : boolean Formats and sends the data to a backend using the suitable method depending on protocol

Méthodes protégées

Méthode Description
sendRequest ( string $path = '/', string $body = '', array $queryData = [], array $headers = [], string $method = "POST", array $options = [], array $postFields = [] ) : http\Client\Response Sends HTTP request with specified params.
sleepWait ( ) Sleeps when an attempt to send data failed
writeFile ( string $message ) : boolean Writes data to a local file
writeHttp ( string $message ) : boolean Sends data over HTTP protocol
writeSocket ( string $message ) : boolean Sends data over a socket, using one of TCP, UDP etc. protocols

Method Details

__construct() public méthode

Constructor. Instantiates the writer.
public __construct ( string $proto = "http", string $path = "localhost", integer $port = 8888, integer $timeout = 1 )
$proto string optional Protocol to use, e.g. http, tcp, udp. Optional.
$path string optional Either a local FS path or hostname/IP for remote.
$port integer optional Port to use if connected to a remote host.
$timeout integer optional How long to wait for reply from the remote end. (seconds)

formatMessage() public méthode

Converts the data into backend acceptable format
public formatMessage ( array $data ) : string
$data array Prepared array of data to convert into JSON format
Résultat string A JSON formatted string

send() public méthode

Formats and sends the data to a backend using the suitable method depending on protocol
public send ( array $data ) : boolean
$data array Prepared array of data to send
Résultat boolean Indicates whether operation was successful

sendRequest() protected méthode

Sends HTTP request with specified params.
protected sendRequest ( string $path = '/', string $body = '', array $queryData = [], array $headers = [], string $method = "POST", array $options = [], array $postFields = [] ) : http\Client\Response
$path string optional Path URL part
$body string optional Raw request POST content
$queryData array optional Associative array of query-string params
$headers array optional Associative array of request headers
$method string optional Request method
$options array optional Request options
$postFields array optional Associative array of post-fields
Résultat http\Client\Response

sleepWait() protected méthode

Sleeps when an attempt to send data failed
protected sleepWait ( )

writeFile() protected méthode

Writes data to a local file
protected writeFile ( string $message ) : boolean
$message string A prepared message for sending
Résultat boolean Indicates whether operation was successful

writeHttp() protected méthode

Sends data over HTTP protocol
protected writeHttp ( string $message ) : boolean
$message string A prepared message for sending
Résultat boolean Indicates whether operation was successful

writeSocket() protected méthode

Sends data over a socket, using one of TCP, UDP etc. protocols
protected writeSocket ( string $message ) : boolean
$message string A prepared message for sending
Résultat boolean Indicates whether operation was successful

Property Details

$host protected_oe property

Either path for local FS or hostname for remote connection
protected string $host
Résultat string

$port protected_oe property

Port to use if connected to a remote host
protected int $port
Résultat integer

$scheme protected_oe property

Protocol to use
protected string $scheme
Résultat string

$timeout protected_oe property

How long to wait for reply from the remote end (seconds)
protected int $timeout
Résultat integer