-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add subscriptions projection #138
Conversation
2d8fe2d
to
b4cb1c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dottorblaster So far so good!
I have done some comments, and maybe let's wait until somebody else reviews it, but I like the code at least!
@@ -0,0 +1,21 @@ | |||
defmodule Tronto.Monitoring.Domain.Commands.UpdateSlesSubscriptions do | |||
@moduledoc """ | |||
Updated data relative to subscriptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update
instead of Updated
@@ -0,0 +1,17 @@ | |||
defmodule Tronto.Monitoring.Domain.Events.SlesSubscriptionsUpdated do | |||
@moduledoc """ | |||
Subscription updated event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add final s
maybe to Subscription
in the docstring
|
||
@derive Jason.Encoder | ||
typedstruct do | ||
@typedoc "Subscription value object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Sles
to the docstring maybe
typedstruct do | ||
@typedoc "Subscription value object" | ||
|
||
field :host_id, String.t(), enforce: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this host_id
field ever used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to have it for completion, I don't have a strong opinion about it 😅
@@ -109,4 +123,42 @@ defmodule Tronto.Monitoring.Integration.Discovery do | |||
nil | |||
end) | |||
end | |||
|
|||
defp parse_subscription_data(host_id, %{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there is any other option to have just an unique function here, instead of 2 with different values. It would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same function with two clauses, (parse_subscription_data/2
). An alternative would be grabbing the optional fields with Map.get
https://hexdocs.pm/elixir/1.12/Map.html#get/3, but I think this version is a bit cleaner and I like the declarative approach
@primary_key false | ||
schema "sles_subscriptions" do | ||
field :host_id, Ecto.UUID, primary_key: true | ||
field :identifier, :string, primary_key: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually @arbulu89 helped me on this one 😄
6deb1a5
to
f3dbd7f
Compare
f2890f2
to
d35e7dc
Compare
As above, we need the subscriptions discovery to be projected in order to have a proper about page and host detail