Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/services/hal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local channel = require "fibers.channel"
local sleep = require "fibers.sleep"

local tablex = require 'shared.table'
local http_sdk = require 'services.http.sdk'

local perform = fibers.perform

Expand Down Expand Up @@ -466,6 +467,15 @@ local function availability_flag(event_type)
return event_type == 'added'
end

local function narrow_http_ref(ref)
if ref == nil then return nil end
return {
status_op = function (_, opts) return ref:status_op(opts) end,
open_exchange_op = function (_, args, opts) return ref:open_exchange_op(args, opts) end,
exchange_op = function (_, args, opts) return ref:exchange_op(args, opts) end,
}
end

local function availability_payload(event_type, extra)
local out = {
state = availability_state(event_type),
Expand Down Expand Up @@ -1082,6 +1092,14 @@ function HalService.start(conn, opts)
component = 'manager',
manager = name,
})
local deps
if name == 'wired' then
deps = {
http_ref_for = function (cap_id)
return narrow_http_ref(http_sdk.new_ref(conn, cap_id or 'main'))
end,
}
end

return perform(manager_call_with_timeout_op(
name,
Expand All @@ -1090,7 +1108,8 @@ function HalService.start(conn, opts)
manager_start_timeout_s,
manager_logger,
dev_ev_ch,
cap_emit_ch
cap_emit_ch,
deps
))
end

Expand Down
Loading