Fix binary protobuf encoding for JSON serializer
- Use base64-encoded binary in JSON payload instead of {:binary, data} tuples
- V1.JSONSerializer cannot encode tuples, needs plain JSON objects
- Agent already sends/expects base64-encoded binary in 'binary' key
This commit is contained in:
parent
9b88a32f33
commit
6b7a3ba36e
1 changed files with 7 additions and 4 deletions
|
|
@ -65,19 +65,21 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
job_list = %AgentJobList{jobs: jobs}
|
||||
binary = AgentJobList.encode(job_list)
|
||||
|
||||
push(socket, "jobs", {:binary, binary})
|
||||
push(socket, "jobs", %{binary: Base.encode64(binary)})
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_in("result", {:binary, binary}, socket) do
|
||||
def handle_in("result", %{"binary" => binary_b64}, socket) do
|
||||
binary = Base.decode64!(binary_b64)
|
||||
result = SnmpResult.decode(binary)
|
||||
process_snmp_result(socket.assigns.organization_id, result)
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_in("heartbeat", {:binary, binary}, socket) do
|
||||
def handle_in("heartbeat", %{"binary" => binary_b64}, socket) do
|
||||
binary = Base.decode64!(binary_b64)
|
||||
heartbeat = AgentHeartbeat.decode(binary)
|
||||
|
||||
metadata = %{
|
||||
|
|
@ -91,7 +93,8 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_in("error", {:binary, binary}, socket) do
|
||||
def handle_in("error", %{"binary" => binary_b64}, socket) do
|
||||
binary = Base.decode64!(binary_b64)
|
||||
error = AgentError.decode(binary)
|
||||
|
||||
Logger.error("Agent job error",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue