Skip to content
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

Merged
merged 7 commits into from
Mar 4, 2022
Merged

Conversation

dottorblaster
Copy link
Contributor

As above, we need the subscriptions discovery to be projected in order to have a proper about page and host detail

@dottorblaster dottorblaster self-assigned this Mar 2, 2022
@dottorblaster dottorblaster changed the title [DRAFT] Add subscriptions projection Add subscriptions projection Mar 3, 2022
@dottorblaster dottorblaster force-pushed the add-subscriptions-projector branch from 2d8fe2d to b4cb1c1 Compare March 3, 2022 14:37
@dottorblaster dottorblaster removed the wip label Mar 3, 2022
Copy link
Contributor

@arbulu89 arbulu89 left a 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.
Copy link
Contributor

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
Copy link
Contributor

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"
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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, %{
Copy link
Contributor

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

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect

Copy link
Contributor Author

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 😄

@dottorblaster dottorblaster force-pushed the add-subscriptions-projector branch from 6deb1a5 to f3dbd7f Compare March 4, 2022 10:05
@dottorblaster dottorblaster force-pushed the add-subscriptions-projector branch from f2890f2 to d35e7dc Compare March 4, 2022 11:51
@dottorblaster dottorblaster merged commit 2c8426f into master Mar 4, 2022
@dottorblaster dottorblaster deleted the add-subscriptions-projector branch March 4, 2022 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants