Here is some improvements to make this crate a bit more production ready:
do not quit the program if there are too much errors (a lib must never take the responsibility of this)
honor the buffer_size config option (the config option was there, but never used)
remove useless Arc<Mutex> in Buffer struct
keep tcp connection open, reconnect on network errors
remove various hardcoded thread::sleep()
remove hardcoded insane 10_000_000 sync_channel bound which eats 2GB (!!!) of RAM because sync_channel always allocate the totality of the buffer, the sync_channel size can now be configured (1000 by default)
export init_processor so rust-log4rs-gelf create do not have to know what struct to create in order to initialize properly the BatchProcessor
implement log::Log::flush (flushes the BatchProcessor)
non blocking logging, even if the buffer is full: a failure in the logging subsystem must not block the application from working
remove Metronome. metronome logic is implemented with recv_timeout directly in Buffer loop. It seems to be a better option to me than the outer thread filling the buffer with Send events.
Hi,
Here is some improvements to make this crate a bit more production ready:
Arc<Mutex>
inBuffer
structsync_channel
bound which eats 2GB (!!!) of RAM because sync_channel always allocate the totality of the buffer, the sync_channel size can now be configured (1000 by default)init_processor
so rust-log4rs-gelf create do not have to know what struct to create in order to initialize properly theBatchProcessor
Metronome
. metronome logic is implemented withrecv_timeout
directly inBuffer
loop. It seems to be a better option to me than the outer thread filling the buffer withSend
events.There are still some room for other improvements: