Sha256: ee2a6a9397ee5d32efefd2362283dbb7d9ed5bd2124aea84eaa49b80670403fa
Contents?: true
Size: 868 Bytes
Versions: 2
Compression:
Stored size: 868 Bytes
Contents
NAME ---- forkhandle SYNOPSIS -------- connection = ForkHandle.get(:db_connection){ Db.connect(config) } DESCRIPTION ----------- managing connection across forks and threads is tricky. most libraries use and icky idiom that requires each and every client to configure it's own forking logic, something like MyLameLib.after_fork do # close handles you should close end many libs also do not provide you with per-thread connection, making MT a manual process. a teeny bit of code can solve both. the concept is simple: maintain a table of connections scoped by process id and thread id. any miss will trigger auto-scrubbing the table, but only connections from another process (we've been forked) will be closed. this gives * per thread connections * per process connections * auto-matic cleanup after a fork
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
forkhandle-0.0.3 | README.md |
forkhandle-0.0.2 | README.md |