This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my project I'm using
influxdb-php
to communicate to an InfluxDB database instance via a Telegraf instance. Since Telegraf exposes a handySocket Listener
plugin (https://docs.influxdata.com/telegraf/v1.9/plugins/inputs/#socket-listener) I decided to use UDP driver, but I found it only works with (obviously) UDP protocol. Socket Listener does support it, but I wanted to be sure in particular cases that message gets through.Reasoning for usage of Telegraf in my case is that I can aggregate writes in it, reducing the amount of messages between application and InfluxDB instance. Also it does send messages in regular intervals in batches, so I don't really need to group messages myself.
It uses InfluxDB's "Line protocol" for messages, so one can either write directly to InfluxDB's UDP socket, or use Telegraf's Socket Listener.
This PR introduces
TCP
class similar toUDP
one and puts common code intoAbstractSocketDriver
. Since I'm no particular expert in socket php functions, I'll welcome any criticism :)