rhaproxy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,110 @@
1
+ # = rhaproxy - A HAproxy gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/rhaproxy
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # class RhaproxyPeers.new( array, str, array)
10
+ #
11
+
12
+ #
13
+ # It is possible to synchronize server entries in stick tables between several
14
+ # haproxy instances over TCP connections in a multi-master fashion. Each instance
15
+ # pushes its local updates and insertions to remote peers. Server IDs are used to
16
+ # identify servers remotely, so it is important that configurations look similar
17
+ # or at least that the same IDs are forced on each server on all participants.
18
+ # Interrupted exchanges are automatically detected and recovered from the last
19
+ # known point. In addition, during a soft restart, the old process connects to
20
+ # the new one using such a TCP connection to push all its entries before the new
21
+ # process tries to connect to other peers. That ensures very fast replication
22
+ # during a reload, it typically takes a fraction of a second even for large
23
+ # tables.
24
+ #
25
+ class RhaproxyPeers
26
+
27
+ #
28
+ # name <peersect>
29
+ # Creates a new peer name <peersect>. It is an independant section,
30
+ # which is referenced by one or more stick-tables.
31
+ #
32
+ attr_accessor :name
33
+
34
+ #
35
+ # peers <peersect>
36
+ # Creates a new peer list with name <peersect>. It is an independant section,
37
+ # which is referenced by one or more stick-tables.
38
+ # This is under the peers_section.
39
+ #
40
+ #
41
+ attr_accessor :peers
42
+
43
+ #
44
+ # peer <peername> <ip>:<port>
45
+ # Defines a peer inside a peers section.
46
+ # If <peername> is set to the local peer name (by default hostname, or forced
47
+ # using "-L" command line option), haproxy will listen for incoming remote peer
48
+ # connection on <ip>:<port>. Otherwise, <ip>:<port> defines where to connect to
49
+ # to join the remote peer, and <peername> is used at the protocol level to
50
+ # identify and validate the remote peer on the server side.
51
+ #
52
+ # During a soft restart, local peer <ip>:<port> is used by the old instance to
53
+ # connect the new one and initiate a complete replication (teaching process).
54
+ #
55
+ # It is strongly recommended to have the exact same peers declaration on all
56
+ # peers and to only rely on the "-L" command line argument to change the local
57
+ # peer name. This makes it easier to maintain coherent configuration files
58
+ # across all peers.
59
+ #
60
+ attr_accessor :peer
61
+
62
+ #
63
+ # Returns a new RhaproxyPeers Object
64
+ #
65
+ def initialize()
66
+ end
67
+
68
+ #
69
+ # Compile the HAproxy peers configuration
70
+ #
71
+ def config
72
+
73
+ if @name
74
+
75
+ conf = option_string()
76
+
77
+ return conf
78
+
79
+ else
80
+
81
+ puts "no peers section name defined"
82
+
83
+ return false
84
+
85
+ end
86
+
87
+ end
88
+
89
+ private
90
+
91
+ def option_string()
92
+
93
+ ostring = " " + "peers " + @name.to_s + "\n"
94
+
95
+ if @peers
96
+ ostring += " " + "peers " + @peers.to_s + "\n"
97
+ end
98
+
99
+ if @peer
100
+ ostring += " " + "peer " + @peer.to_s + "\n"
101
+ end
102
+
103
+ ostring += "\n"
104
+
105
+ return ostring
106
+
107
+ end
108
+
109
+ end
110
+
@@ -0,0 +1,93 @@
1
+ # = rhaproxy - A HAproxy gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/rhaproxy
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # class RhaproxyUserlist.new( array, str, array)
10
+ #
11
+
12
+ #
13
+ # It is possible to control access to frontend/backend/listen sections or to
14
+ # http stats by allowing only authenticated and authorized users. To do this,
15
+ # it is required to create at least one userlist and to define users.
16
+ #
17
+ class RhaproxyUserlist
18
+
19
+ #
20
+ # name <listname>
21
+ # Creates new userlist with name <listname>. Many independent userlists can be
22
+ # used to store authentication & authorization data for independent customers.
23
+ #
24
+ attr_accessor :name
25
+
26
+ #
27
+ # group <groupname> [users <user>,<user>,(...)]
28
+ # Adds group <groupname> to the current userlist. It is also possible to
29
+ # attach users to this group by using a comma separated list of names
30
+ # proceeded by "users" keyword.
31
+ #
32
+ attr_accessor :group
33
+
34
+ #
35
+ # user <username> [password|insecure-password <password>]
36
+ # [groups <group>,<group>,(...)]
37
+ # Adds user <username> to the current userlist. Both secure (encrypted) and
38
+ # insecure (unencrypted) passwords can be used. Encrypted passwords are
39
+ # evaluated using the crypt(3) function so depending of the system's
40
+ # capabilities, different algorithms are supported. For example modern Glibc
41
+ # based Linux system supports MD5, SHA-256, SHA-512 and of course classic,
42
+ # DES-based method of crypting passwords.
43
+ #
44
+ attr_accessor :user
45
+
46
+ #
47
+ # Returns a new RhaproxyUserlist Object
48
+ #
49
+ def initialize()
50
+ end
51
+
52
+ #
53
+ # Compile the HAproxy userlist configuration
54
+ #
55
+ def config
56
+
57
+ if @name
58
+
59
+ conf = option_string()
60
+
61
+ return conf
62
+
63
+ else
64
+
65
+ puts "no userlists name defined"
66
+
67
+ return false
68
+
69
+ end
70
+
71
+ end
72
+
73
+ private
74
+
75
+ def option_string()
76
+
77
+ ostring = " " + "userlist " + @name + "\n"
78
+
79
+ if @group
80
+ ostring += " " + "group " + @group + "\n"
81
+ end
82
+
83
+ if @user
84
+ ostring += " " + "user " + @user + "\n"
85
+ end
86
+
87
+ ostring += "\n"
88
+
89
+ return ostring
90
+
91
+ end
92
+ end
93
+
@@ -0,0 +1,17 @@
1
+ # = rhaproxy - A HAproxy gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/rhaproxy
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ module RHAproxy #:nodoc:
9
+ module VERSION #:nodoc:
10
+ MAJOR = 0
11
+ MINOR = 1
12
+ TINY = 0
13
+
14
+ STRING = [MAJOR, MINOR, TINY].join('.')
15
+ end
16
+ end
17
+
data/lib/rhaproxy.rb ADDED
@@ -0,0 +1,9 @@
1
+ # = rhaproxy - A HAproxy gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/rhaproxy
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ Dir[File.join(File.dirname(__FILE__), 'rhaproxy/**/*.rb')].sort.each { |lib| require lib }
9
+