Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #4 adds backend and server logic to new classes #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

logicminds
Copy link
Contributor

I am not sure this is quite ready to merge, as I haven't fixed the documentation yet nor tested with real haproxy instances, but in the following days this should be ready to merge. Have a look as this is a major change. All unit tests are passing at this point. I'll be playing around with this new code in a real environment this week but you can review this for now. Its pretty functional and allows one to play around with server or backend objects instead of the instance. The objects are scoped so you only see backend or server related information gathered from the stats.

I also moved the socket to its own file in case the user wants to create a server or backend object without using the instance object.

These new objects will create a bunch more chatter on the socket channel so I was thinking of going back and adding some sort of cache layer to HAPSocket to reduce the number of calls to the socket. Not sure what would happen to haproxy if the socket is over utilized.

To use you essentially do the following:

haproxy = HAProxyManager::Instance.new ('path to haproxy socket')
servers = haproxy.server_instances
backends = haproxy.backend_instances
servers.each do |srvid, server|
    puts server.name
    puts server.weight
    puts server.up?
    puts server.bin  (bytes in, dynamic method via method missing)
end

@sreeix
Copy link
Contributor

sreeix commented Dec 3, 2013

Looks good. I would not worry about the socket chatter, we should first test it and see how haproxy deals with it. I am certain it will not have issues.

@logicminds
Copy link
Contributor Author

I have updated the read me file. Been using the new API for a few weeks without issues. This should be good to merge now and ready for mass consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants