Loggability::LogDevice::
Http class
Superclass | Loggability::LogDevice |
This is the a generalized class that allows its subclasses to send log messages to HTTP endpoints asynchronously on a separate thread.
Constants
- DEFAULT_BATCH_INTERVAL
The default number of seconds between batches
- DEFAULT_ENDPOINT
The default HTTP endpoint URL to send logs to
- DEFAULT_EXECUTOR_CLASS
The default Executor class to use for asynchronous tasks
- DEFAULT_MAX_BATCH_SIZE
The default maximum number of messages that can be sent to the server in a single payload
- DEFAULT_MAX_MESSAGE_BYTESIZE
The default max size in bytes for a single message.
- DEFAULT_MAX_QUEUE_BYTESIZE
The default for the maximum bytesize of the queue (1 GB)
- DEFAULT_OPTIONS
The default options for new instances
- DEFAULT_WRITE_TIMEOUT
The default number of seconds to wait for data to be written before timing out
Attributes
- batch_interval R
Number of seconds after the task completes before the task is performed again.
- endpoint R
The URI of the endpoint to send messages to
- executor R
The single thread pool executor
- executor_class R
The Concurrent executor class to use for asynchronous tasks
- last_send_time RW
The monotonic clock time when the last batch of logs were sent
- logs_queue R
The Queue that contains any log messages which have not yet been sent to the logging service.
- logs_queue_bytesize RW
The size of
logs_queue
in bytes- max_batch_bytesize R
The maximum number of bytes that will be included in a single POST
- max_batch_size R
The maximum number of messages to post at one time
- max_message_bytesize R
The maximum number of bytes of a single message to include in a batch
- max_queue_bytesize R
The max bytesize of the queue. Will not queue more messages if this threshold is hit
- timer_task R
The timer task thread
- write_timeout R
How many seconds to wait for data to be written while sending a batch
Public Class Methods
Initialize the HTTP log device to send to the specified endpoint
with the given options
. Valid options are:
Maximum number of seconds between batches
How many seconds to wait for data to be written while sending a batch
The maximum number of messages that can be in a single batch
The maximum number of bytes that can be in the payload of a single batch
The maximum number of bytes that can be in a single message
The Concurrent executor class to use for asynchronous tasks.
Public Instance Methods
Returns true
if a batch of logs is ready to be sent.
LogDevice API – stop the batch thread and close the http connection
Returns the given message
in whatever format individual log messages are expected to be in by the service. The default just returns the stringified message
. This executes inside the sending thread.
Dequeue pending log messages to send to the service and return them as a suitably-encoded String. The default is a JSON Array. This executes inside the sending thread.
sets up a configured http object ready to instantiate connections
Returns a new HTTP request (a subclass of Net::HTTPRequest) suitable for sending the next batch of logs to the service. Defaults to a POST of JSON data. This executes inside the sending thread.
Returns true
if the device has started sending messages to the logging endpoint.
Sends a batch of log messages to the logging service. This executes inside the sending thread.
Starts a thread pool with a single thread.
Start the background thread that sends messages.
Create a timer task that calls that sends logs at regular interval
Shutdown the executor, which is a pool of single thread waits 3 seconds for shutdown to complete
LogDevice API – write a message to the HTTP device.