blob: d22ed87f16e5b43bc50502a70929a7e56754e912 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# encoding: UTF-8
require 'mauve/server'
require 'mauve/configuration_builder'
module Mauve
module ConfigurationBuilders
#
# This is the HTTP server
#
class HTTPServer < ObjectBuilder
# The port the http server listens on
is_attribute "port"
# The IP address the http server listens on. IPv6 is *NOT* OK.
is_attribute "ip"
# Where all the templates are kept
is_attribute "document_root"
# The secret for the cookies
is_attribute "session_secret"
# The base URL of the server.
is_attribute "base_url"
# Sets up a Mauve::HTTPServer singleton as the result
#
# @return [Mauve::HTTPServer]
def builder_setup
@result = Mauve::HTTPServer.instance
end
end
#
# This is the UDP server.
#
class UDPServer < ObjectBuilder
# This is the port the server listens on
is_attribute "port"
# This is the IP address the server listens on. IPv6 is OK! e.g. [::] for all addresses
is_attribute "ip"
# This is the sleep interval for the UDP server.
is_attribute "poll_every"
# Sets up a Mauve::UDPServer singleton as the result
#
# @return [Mauve::UDPServer]
def builder_setup
@result = Mauve::UDPServer.instance
end
end
#
# This is the thread that pulls packets from the queue for processing.
#
class Processor < ObjectBuilder
# This is the interval between polls of the packet queue.
is_attribute "poll_every"
# This is the timeout for the transmission cache, which allows duplicate packets to be discarded.
is_attribute "transmission_cache_expire_time"
# Sets up a Mauve::Processor singleton as the result
#
# @return [Mauve::Processor]
def builder_setup
@result = Mauve::Processor.instance
end
end
class Notifier < ObjectBuilder
#
# This is the interval at which the notification queue is polled for new
# notifications to be sent. This will not have any rate-limiting effect.
#
is_attribute "poll_every"
# Sets up a Mauve::Notifier singleton as the result
#
# @return [Mauve::Notifier]
def builder_setup
@result = Mauve::Notifier.instance
end
end
#
# This sends a mauve heartbeat to another Mauve instance elsewhere
#
class Heartbeat < ObjectBuilder
#
# The destination for the heartbeat
#
is_attribute "destination"
#
# The detail field for the heartbeat
#
is_attribute "detail"
#
# The summary field for the heartbeat.
#
is_attribute "summary"
#
# How long to raise an alert after the last heartbeat.
#
is_attribute "raise_after"
#
# The interval between heartbeats
#
is_attribute "send_every"
# Sets up a Mauve::Heartbeat singleton as the result
#
# @return [Mauve::Heartbeat]
def builder_setup
@result = Mauve::Heartbeat.instance
end
end
class Pop3Server < ObjectBuilder
#
# The IP adderess the Pop3 server listens on
#
is_attribute "ip"
#
# The POP3 server port
#
is_attribute "port"
# Sets up a Mauve::Pop3Server singleton as the result
#
# @return [Mauve::Pop3Server]
def builder_setup
@result = Mauve::Pop3Server.instance
end
end
#
# This is the main Server singleton.
#
class Server < ObjectBuilder
#
# Set up second-level builders
#
is_builder "web_interface", HTTPServer
is_builder "listener", UDPServer
is_builder "processor", Processor
is_builder "notifier", Notifier
is_builder "heartbeat", Heartbeat
is_builder "pop3_server", Pop3Server
#
# The name of the server this instance of Mauve is running on
#
is_attribute "hostname"
#
# The database definition
#
is_attribute "database"
#
# The period of sleep during which no heartbeats are raised.
#
is_attribute "initial_sleep"
#
# The next two attributes determine if packet/notitication bufferes are
# used. These both default to "true"
#
is_attribute "use_packet_buffer"
is_attribute "use_notification_buffer"
#
# This is where the calendar is located. The request paths are hard-coded.
#
is_attribute "bytemark_calendar_url"
#
# This is where the Bytemark authentication server is located.
#
is_attribute "bytemark_auth_url"
#
# This is the level of SSL verification used when making external HTTPS connections.
#
is_attribute "remote_https_verify_mode"
#
# This is the default timeout when making remote HTTP requests
#
is_attribute "remote_http_timeout"
#
# This is the default sleep time after an authentication attempt has failed.
#
is_attribute "failed_login_delay"
def builder_setup
@result = Mauve::Server.instance
end
end
end
#
# Add server to our top-level config builder
#
class ConfigurationBuilder < ObjectBuilder
is_builder "server", ConfigurationBuilders::Server
# This is called once the server object has been created.
#
# @raise [SyntaxError] if more than one server clause has been defined.
#
def created_server(server)
raise SyntaxError.new("Only one 'server' clause can be specified") if @result.server
@result.server = server
end
end
end
|