Class: DRab::DRabServer
- Inherits:
-
Object
show all
- Defined in:
- lib/drab/invokemethod.rb,
lib/drab/drab.rb
Overview
Defined Under Namespace
Modules: InvokeMethod18Mixin
Classes: InvokeMethod
Constant Summary
collapse
- @@acl =
nil
- @@idconv =
DRabIdConv.new
- @@secondary_server =
nil
- @@argc_limit =
256
- @@load_limit =
256 * 102400
- @@verbose =
false
- @@safe_level =
0
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(uri = nil, front = nil, config_or_acl = nil) ⇒ DRabServer
Returns a new instance of DRabServer.
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
|
# File 'lib/drab/drab.rb', line 1150
def initialize(uri=nil, front=nil, config_or_acl=nil)
if Hash === config_or_acl
config = config_or_acl.dup
else
acl = config_or_acl || @@acl
config = {
:tcp_acl => acl
}
end
@config = self.class.make_config(config)
@protocol = DRabProtocol.open_server(uri, @config)
@uri = @protocol.uri
@exported_uri = [@uri]
@secret = @config[:secret]
@front = front
@idconv = @@idconv
@safe_level = @config[:safe_level]
@grp = ThreadGroup.new
@thread = run
DRab.regist_server(self)
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
1185
1186
1187
|
# File 'lib/drab/drab.rb', line 1185
def config
@config
end
|
#front ⇒ Object
Returns the value of attribute front.
1183
1184
1185
|
# File 'lib/drab/drab.rb', line 1183
def front
@front
end
|
#safe_level ⇒ Object
Returns the value of attribute safe_level.
1187
1188
1189
|
# File 'lib/drab/drab.rb', line 1187
def safe_level
@safe_level
end
|
#secret ⇒ Object
Returns the value of attribute secret.
1179
1180
1181
|
# File 'lib/drab/drab.rb', line 1179
def secret
@secret
end
|
#thread ⇒ Object
Returns the value of attribute thread.
1181
1182
1183
|
# File 'lib/drab/drab.rb', line 1181
def thread
@thread
end
|
#uri ⇒ Object
Returns the value of attribute uri.
1177
1178
1179
|
# File 'lib/drab/drab.rb', line 1177
def uri
@uri
end
|
Class Method Details
.default_acl(acl) ⇒ Object
1122
1123
1124
|
# File 'lib/drab/drab.rb', line 1122
def self.default_acl(acl)
@@acl = acl
end
|
.default_argc_limit(argc) ⇒ Object
1114
1115
1116
|
# File 'lib/drab/drab.rb', line 1114
def self.default_argc_limit(argc)
@@argc_limit = argc
end
|
.default_load_limit(sz) ⇒ Object
1118
1119
1120
|
# File 'lib/drab/drab.rb', line 1118
def self.default_load_limit(sz)
@@load_limit = sz
end
|
.default_safe_level(level) ⇒ Object
1126
1127
1128
|
# File 'lib/drab/drab.rb', line 1126
def self.default_safe_level(level)
@@safe_level = level
end
|
.make_config(hash = {}) ⇒ Object
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
|
# File 'lib/drab/drab.rb', line 1138
def self.make_config(hash={})
default_config = {
:verbose => @@verbose,
:tcp_acl => @@acl,
:load_limit => @@load_limit,
:argc_limit => @@argc_limit,
:safe_level => @@safe_level,
:secret => nil
}
default_config.update(hash)
end
|
.verbose ⇒ Object
1134
1135
1136
|
# File 'lib/drab/drab.rb', line 1134
def self.verbose
@@verbose
end
|
.verbose=(on) ⇒ Object
1130
1131
1132
|
# File 'lib/drab/drab.rb', line 1130
def self.verbose=(on)
@@verbose = on
end
|
Instance Method Details
#alive? ⇒ Boolean
1193
1194
1195
|
# File 'lib/drab/drab.rb', line 1193
def alive?
@thread.alive?
end
|
#check_insecure_method(obj, msg_id) ⇒ Object
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
|
# File 'lib/drab/drab.rb', line 1258
def check_insecure_method(obj, msg_id)
return true if Proc === obj && msg_id == :__drab_yield
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
if obj.private_methods.include?(msg_id)
desc = any_to_s(obj)
raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
elsif obj.protected_methods.include?(msg_id)
desc = any_to_s(obj)
raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
else
true
end
end
|
#here?(uri) ⇒ Boolean
1197
1198
1199
|
# File 'lib/drab/drab.rb', line 1197
def here?(uri)
@exported_uri.include?(uri)
end
|
#stop_service ⇒ Object
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
|
# File 'lib/drab/drab.rb', line 1201
def stop_service
DRab.remove_server(self)
if Thread.current['DRab'] && Thread.current['DRab']['server'] == self
Thread.current['DRab']['stop_service'] = true
else
if @protocol.respond_to? :shutdown
@protocol.shutdown
else
[@thread, *@grp.list].each {|thread| thread.kill}
end
@thread.join
end
end
|
#to_id(obj) ⇒ Object
1222
1223
1224
1225
|
# File 'lib/drab/drab.rb', line 1222
def to_id(obj)
return nil if obj.__id__ == front.__id__
@idconv.to_id(obj)
end
|
#to_obj(ref) ⇒ Object
1215
1216
1217
1218
1219
1220
|
# File 'lib/drab/drab.rb', line 1215
def to_obj(ref)
return front if ref.nil?
return front[ref] if ref.is_a? String
@idconv.to_obj(ref)
end
|
#verbose ⇒ Object
1191
|
# File 'lib/drab/drab.rb', line 1191
def verbose; @config[:verbose]; end
|
#verbose=(v) ⇒ Object
1189
|
# File 'lib/drab/drab.rb', line 1189
def verbose=(v); @config[:verbose]=v; end
|