jacquayj / GoRODS

Golang binding for iRODS C API: An iRODS client library written in Golang + C
https://godoc.org/github.com/jjacquay712/GoRODS
BSD 3-Clause "New" or "Revised" License
17 stars 5 forks source link

Implement iRods Connection Pooling #20

Closed jjacquay712 closed 8 years ago

jjacquay712 commented 8 years ago

Proposed syntax:

gorods.connpool.New(int connExpire, int maxConn) // create connection pool, specify timeout (s) for connections, maximum connections (calls Expire() first and then closes oldest connection when none were expired on each Open() after maxxConn is reached)
gorods.connpool.Expire() // close/disconnect all expired connections
gorods.connpool.Open(string userName, etc... ) // calls gorods.New() for a given iRODS user and registers them in the pool, timestamped for expiration, etc.
gorods.connpool.Close(string userName) // explicit close/disconect of a connection (from logout, etc.) from the pool
gorods.connpool.Get(string userName) // returns the GoRods connection for the username
jjacquay712 commented 8 years ago

After some investigation, I've found that using a single GoRods connection within multiple Goroutines (from net/http server) causes low-level network library errors. This issue could be remedied with connection pooling, transparent to the implementer of GoRods:

jacquayj commented 8 years ago

I've found that data object and collection handles must be used only with the same connection they were created with, so that makes the idea of connection pools difficult to implement and not very worth while. The iRODS authors also state "The view I take is that iRODS has grown over time based on the 'icommand' model, where a command connects, does its job, and then disconnects. Especially if your client is widely distributed, my own best practice is to avoid holding on to idle connections. There can also be dangers of dropping connections that are idle if you are overly reliant on continuously held connections.".