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

add backend and server class #4

Open
logicminds opened this issue Oct 31, 2013 · 0 comments
Open

add backend and server class #4

logicminds opened this issue Oct 31, 2013 · 0 comments

Comments

@logicminds
Copy link
Contributor

I started a branch in order to create more objects to make using the library easier.

The plan is to separate out the backends and servers into objects that can be controlled and queried indepently using object methods. I just wanted to share what I will be doing in case you had different design goals or additional input. So for example.

instance.backends.first.servers  # returns a list of servers in the backend
instance.backends.first.name    # backend name
instance.backends.first.stats     # returns stats
instance.backends.first.downtime  # returns downtime stat
instance.servers.first.name    # returns the server name/id
instance.servers.first.stats     # returns the stats of the server
instance.servers.first.downtime # returns the downtime stat
instance.servers.first.backends # returns the backends the server belongs to
instance.servers.first.disable(backend='all')  # disables the server for the backend(s)

I plan to use method_missing to create dynamic methods for stats so that each object appears to have implemented a method to return a paticular stat. This will be in the server and backend object.

example:

def method_missing(method, *args, &block)
      if not stats.has_key?(method.to_s)
        raise NoMethodError
      else
       stats[method.to_s]
      end
    end

https://github.com/logicminds/haproxy_manager/blob/backend_class/lib/haproxy_manager

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

No branches or pull requests

1 participant