mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Initial functioning work to get IPC working via UNIX sockets since ractors are still not a viable option :sad:
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Helper for launcher frontend to safely communicate with ractor (prevent deadlocks and concurrent access errors)
|
||||
# Helper for launcher frontend to safely communicate with launcher backend
|
||||
|
||||
module W3DHubLauncher
|
||||
class Worker
|
||||
|
||||
@@ -47,7 +47,7 @@ module W3DHubLauncher
|
||||
|
||||
def enqueue(type, id, data)
|
||||
Request.requests << self
|
||||
W3DHubLauncher::WORKER.send(Query.new(type, id, data))
|
||||
W3DHubLauncher::WORKER.request(Query.new(type, id, data))
|
||||
end
|
||||
|
||||
# event from Worker received
|
||||
|
||||
@@ -21,7 +21,7 @@ module W3DHubLauncher
|
||||
array << ["content-type", "application/x-www-form-urlencoded"] if form_encoded
|
||||
array << ["authorization", "Bearer #{@access_token}"] if @access_token
|
||||
|
||||
pp array
|
||||
# pp array
|
||||
|
||||
array
|
||||
end
|
||||
@@ -36,6 +36,7 @@ module W3DHubLauncher
|
||||
if response.success?
|
||||
result.data = response.read
|
||||
else
|
||||
pp response
|
||||
result.error = true
|
||||
end
|
||||
end
|
||||
@@ -99,9 +100,24 @@ module W3DHubLauncher
|
||||
|
||||
def fetch_applications
|
||||
result = CyberarmEngine::Result.new
|
||||
primary_result = fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
|
||||
# If we're not signed in, then the primary backend will try to redirect us to the alternate backend. So skip it if we're not signed in.
|
||||
primary_result = @access_token ? fetch("#{PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications") : CyberarmEngine::Result.new(error: true)
|
||||
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
|
||||
|
||||
# We've failed to retrieve data
|
||||
if primary_result.error? && alternate_result.error?
|
||||
return result
|
||||
# We've only gotten data back from the primary backend
|
||||
elsif primary_result.okay? && alternate_result.error?
|
||||
result.data = primary_result.data
|
||||
return result
|
||||
# We've only gotten data back from the alternate backend
|
||||
elsif primary_result.error? && alternate_result.okay?
|
||||
result.data = alternate_result.data
|
||||
return result
|
||||
end
|
||||
|
||||
# We've gotten data back from both backends, merge them.
|
||||
pp [primary_result, alternate_result]
|
||||
|
||||
# FIXME: Merge primary and alternate results
|
||||
|
||||
Reference in New Issue
Block a user