resurfaceio / logger-python

Log API calls with Python
Apache License 2.0
22 stars 6 forks source link

Background submission with dedicated thread #26

Open RobDickinson opened 3 years ago

RobDickinson commented 3 years ago

Send POST requests on a separate thread with bounded queue. Introduce BaseLogger.maxQueueDepth (with default value of 128) to control the depth of the bounded queue before the response is blocked.

BaseLogger.submit is where the handoff to the background thread should be done. (Rules engine and JSON conversion will continue to be done in the calling thread)

BaseLogger needs only a single background thread for performing POST requests since a single CPU core is normally capable of saturating the network.