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 approval service listener #168

Merged

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Mar 21, 2019

Adds the Approval Request Listener including a bin file for development environments.

Kafka Published Topics (Events) Are as follows: ( at create of the request )

    :payload  => {
      :request_id => '1'
    }

When the request is approved

    :payload  => {
      :request_id => '1'
      :decision =>"approved", 
      :reason"=>"System approved"
    }

@syncrou
Copy link
Contributor Author

syncrou commented Mar 21, 2019

@lindgrenj6 please review

@syncrou syncrou requested review from bzwei, eclarizio and mkanoor March 21, 2019 19:54
@syncrou syncrou assigned gmcculloug and mkanoor and unassigned eclarizio, mkanoor and bzwei Mar 21, 2019
@syncrou syncrou added the enhancement New feature or request label Mar 21, 2019
Copy link
Contributor

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

Waiting for specs to submit full review

@syncrou syncrou force-pushed the add_approval_service_listener branch from 35fd5de to 9006c0d Compare March 25, 2019 18:16
@syncrou syncrou force-pushed the add_approval_service_listener branch from 9006c0d to c580166 Compare March 26, 2019 14:47
@syncrou syncrou marked this pull request as ready for review March 26, 2019 14:47
@syncrou syncrou requested review from bzwei, mkanoor and eclarizio March 26, 2019 14:47
@syncrou syncrou force-pushed the add_approval_service_listener branch 2 times, most recently from edb5064 to 97d9de4 Compare March 26, 2019 15:25
@syncrou syncrou force-pushed the add_approval_service_listener branch 2 times, most recently from d697ec3 to d988ac7 Compare March 26, 2019 17:51
Copy link
Contributor

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@syncrou syncrou force-pushed the add_approval_service_listener branch from d988ac7 to f97698a Compare March 26, 2019 18:04
Copy link
Contributor

@lindgrenj6 lindgrenj6 left a comment

Choose a reason for hiding this comment

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

LGTM!

require "bundler/setup"
require "approval_request_listener"

queue_host = ENV["QUEUE_HOST"] || "localhost"
Copy link
Contributor

Choose a reason for hiding this comment

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

@syncrou can these 4 lines be wrapped into a function and reused here and in config/initializers/approval_request_listener maybe as a class method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it would only be queue_host and queue_port which should be moved to a generic place where all environmental variables are set. We have the same problem with the service order listener. I created this #174 to handle that in a future PR.

@syncrou syncrou force-pushed the add_approval_service_listener branch from f97698a to 68cb4f1 Compare March 26, 2019 20:19
Handle denied and approved requests
Add specs around the listener
@syncrou syncrou force-pushed the add_approval_service_listener branch 2 times, most recently from cff7658 to 9adc58c Compare March 26, 2019 21:40
@@ -40,7 +40,7 @@ def set_defaults
end

def update_message(level, message)
self.updated_at = DateTime.now
self.updated_at = Time.zone.now
Copy link
Contributor

Choose a reason for hiding this comment

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

@syncrou This should be in GMT correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be if we set the rails app config default time to UTC
That's what the zone method does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though it may be that by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, default is UTC - http://patrikonrails.com/posts/2

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the update_at field get updated automatically at record saving time?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bzwei @syncrou This is creating a child object the parent will not get automatically updated.

Copy link
Contributor

@mkanoor mkanoor left a comment

Choose a reason for hiding this comment

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

We need to account for errors and tenancy which can be done in a separate PR.

@@ -40,7 +40,7 @@ def set_defaults
end

def update_message(level, message)
self.updated_at = DateTime.now
self.updated_at = Time.zone.now
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the update_at field get updated automatically at record saving time?

@syncrou syncrou force-pushed the add_approval_service_listener branch from 9adc58c to 11db84e Compare March 27, 2019 12:57
lib/approval_request_listener.rb Outdated Show resolved Hide resolved
lib/approval_request_listener.rb Outdated Show resolved Hide resolved
lib/approval_request_listener.rb Outdated Show resolved Hide resolved
lib/approval_request_listener.rb Outdated Show resolved Hide resolved
lib/approval_request_listener.rb Outdated Show resolved Hide resolved
@syncrou syncrou force-pushed the add_approval_service_listener branch 2 times, most recently from f606cb6 to 6adbdc6 Compare March 27, 2019 19:04
A progress message only has value if there is an order attached to it
Since we have now order we are now logging the full payload to the
logger so we would have the data available to us in case there was no record found
with the request id in ApprovalRequest
@syncrou syncrou force-pushed the add_approval_service_listener branch from 6adbdc6 to 9846d10 Compare March 27, 2019 19:13
@miq-bot
Copy link
Collaborator

miq-bot commented Mar 27, 2019

Checked commits syncrou/catalog-api@2cb1cc9~...9846d10 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 0 offenses detected
Everything looks fine. 🍪

@syncrou syncrou requested a review from bzwei March 27, 2019 19:24
@gmcculloug gmcculloug merged commit daa356d into RedHatInsights:master Mar 27, 2019
gmcculloug pushed a commit to gmcculloug/catalog-api that referenced this pull request Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants