PHP Класс Scalr\LogCollector\Writers\AbstractWriter

Автор: Constantine Karnacevych ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$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)

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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() публичный Метод

Converts the data into backend acceptable format
public formatMessage ( array $data ) : string
$data array Prepared array of data to convert into JSON format
Результат string A JSON formatted string

send() публичный Метод

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
Результат boolean Indicates whether operation was successful

sendRequest() защищенный Метод

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
Результат http\Client\Response

sleepWait() защищенный Метод

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

writeFile() защищенный Метод

Writes data to a local file
protected writeFile ( string $message ) : boolean
$message string A prepared message for sending
Результат boolean Indicates whether operation was successful

writeHttp() защищенный Метод

Sends data over HTTP protocol
protected writeHttp ( string $message ) : boolean
$message string A prepared message for sending
Результат boolean Indicates whether operation was successful

writeSocket() защищенный Метод

Sends data over a socket, using one of TCP, UDP etc. protocols
protected writeSocket ( string $message ) : boolean
$message string A prepared message for sending
Результат boolean Indicates whether operation was successful

Описание свойств

$host защищенное свойство

Either path for local FS or hostname for remote connection
protected string $host
Результат string

$port защищенное свойство

Port to use if connected to a remote host
protected int $port
Результат integer

$scheme защищенное свойство

Protocol to use
protected string $scheme
Результат string

$timeout защищенное свойство

How long to wait for reply from the remote end (seconds)
protected int $timeout
Результат integer