osquery / osquery-go

Go bindings for osquery
MIT License
386 stars 78 forks source link

Add mutexes to osquery-go #99

Closed directionless closed 1 year ago

directionless commented 2 years ago

As discussed in #98, osquery's communication is single threaded. This PR adds several mechanisms to help manage that.

  1. Most critically, it adds mutexes to the underlying client calls to enforce that.
  2. It exposes the Context version of the underlying thrift library. Thrift documents some amount of retry logic, if contexts have deadlines, though I cannot tell if it works. It's also a little scaffolding to support using limiters
  3. It adds a WithClient option to NewExtensionManagerServer. The intent of this is to allow an application to reuse the same client for the client portions of server communication.

I'm probably willing to rework this to use a rate.Limiter if people thought that was a better idea

Fixes: #98

directionless commented 2 years ago

Hrm. One caveat I see here, is that I've added mutexes, but not timeouts. Which strikes me as a somewhat dangerous.