Class: LS4::DataServerURLService

Inherits:
Service show all
Defined in:
lib/ls4/service/data_server_url.rb

Instance Method Summary collapse

Methods inherited from Service

init

Methods included from EventBus::SingletonMixin

#ebus_bind!, #ebus_connect, extended

Methods included from EventBus::BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from EventBus::DeclarerBase::Methods

#connect, #ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from EventBus::DeclarerBase

#call_slot, #signal_slot

Constructor Details

#initializeDataServerURLService

%p path encoded key %k url encoded key %v vtime %r rsid



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ls4/service/data_server_url.rb', line 26

def initialize
	host = ConfigBus.self_address.host
	if redirect_http_port = ConfigBus.http_redirect_port
		if redirect_http_path_format = ConfigBus.http_redirect_path_format
			@format = "http://#{host}:#{redirect_http_port}/#{redirect_http_path_format}"
			@format << '%p' unless @format.include?('%')
		else
			@format = "http://#{host}:#{redirect_http_port}/%p"
		end

	elsif self_http_address = ConfigBus.http_gateway_address
		@format = "http://#{host}:#{self_http_address.port}/direct/%r/%v/%k"

	else
		@format = nil
	end
end

Instance Method Details

#rpc_url_direct(okey) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ls4/service/data_server_url.rb', line 44

def rpc_url_direct(okey)
	unless @format
		raise "redirect url is not configured"
	end

	unless StorageBus.exist(okey.vtime, okey.key)
		return nil
	end

	format_url(okey)
end