implement a special decoder for the id
All checks were successful
Build and Publish / build-release (push) Successful in 1m23s
All checks were successful
Build and Publish / build-release (push) Successful in 1m23s
This commit is contained in:
@@ -1,39 +1,58 @@
|
|||||||
defmodule WorkloadService.Events do
|
defmodule WorkloadService.Events do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
All domain events for the workload service.
|
All domain events for the workload service.
|
||||||
|
Contains helpers for common event functionality.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
defmodule TaskCreated do
|
alias WorkloadService.Aggregates.TaskId
|
||||||
|
|
||||||
|
defmacro __using__(_opts) do
|
||||||
|
quote do
|
||||||
|
defimpl Commanded.Serialization.JsonDecoder do
|
||||||
|
def decode(%{id: %{org_id: org_id, type: type, task_id: task_id}} = event) do
|
||||||
|
%{event | id: TaskId.new(org_id, type, task_id)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def decode(event), do: event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defmodule WorkloadService.Events.TaskCreated do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Emitted when a new task is created (quote or solicitation).
|
Emitted when a new task is created (quote or solicitation).
|
||||||
ID format: "org_id:type:task_id" (e.g., "test:quote:uuid") - TaskId struct
|
ID format: "org_id:type:task_id" (e.g., "test:quote:uuid") - TaskId struct
|
||||||
"""
|
"""
|
||||||
|
use WorkloadService.Events
|
||||||
@derive Jason.Encoder
|
@derive Jason.Encoder
|
||||||
defstruct [:id, :application_id, :task_info, :attachments]
|
defstruct [:id, :application_id, :task_info, :attachments]
|
||||||
end
|
end
|
||||||
|
|
||||||
defmodule SubmissionUpdated do
|
defmodule WorkloadService.Events.SubmissionUpdated do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Emitted when submission is updated (user provides response data).
|
Emitted when submission is updated (user provides response data).
|
||||||
"""
|
"""
|
||||||
|
use WorkloadService.Events
|
||||||
@derive Jason.Encoder
|
@derive Jason.Encoder
|
||||||
defstruct [:id, :submission, :attachments]
|
defstruct [:id, :submission, :attachments]
|
||||||
end
|
end
|
||||||
|
|
||||||
defmodule SubmissionApproved do
|
defmodule WorkloadService.Events.SubmissionApproved do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Emitted when submission is approved and ready to send.
|
Emitted when submission is approved and ready to send.
|
||||||
"""
|
"""
|
||||||
|
use WorkloadService.Events
|
||||||
@derive Jason.Encoder
|
@derive Jason.Encoder
|
||||||
defstruct [:id]
|
defstruct [:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
defmodule TaskCompleted do
|
defmodule WorkloadService.Events.TaskCompleted do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Emitted when task is completed and sent to policy-service.
|
Emitted when task is completed and sent to policy-service.
|
||||||
Triggers RabbitMQ publish.
|
Triggers RabbitMQ publish.
|
||||||
"""
|
"""
|
||||||
|
use WorkloadService.Events
|
||||||
@derive Jason.Encoder
|
@derive Jason.Encoder
|
||||||
defstruct [:id, :completed_by]
|
defstruct [:id, :completed_by]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user