Skip to content

add backend and server class #4

@logicminds

Description

@logicminds

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions