Add system notifications service to health check endpoint [SCI-3522]

This commit is contained in:
Oleksii Kriuchykhin 2019-05-31 15:52:47 +02:00
parent 94b220172d
commit 552f69b9b1
2 changed files with 13 additions and 0 deletions

View file

@ -36,6 +36,11 @@ module Api
def health
User.new && Team.new && Project.new
User.first if params[:db]
if Rails.application.secrets.system_notifications_uri.present? &&
Rails.application.secrets.system_notifications_channel.present? &&
!Notifications::SyncSystemNotificationsService.available?
return render plain: 'SYSTEM NOTIFICATIONS SERVICE CHECK FAILED', status: :error
end
render plain: 'RUNNING'
end

View file

@ -24,6 +24,14 @@ module Notifications
@errors.none?
end
def self.available?
channel = Rails.application.secrets.system_notifications_channel
query = { query: { last_sync_timestamp: Time.now.to_i, channels_slug: channel },
headers: { 'accept': 'application/vnd.system-notifications.1+json' } }
response = get('/api/system_notifications', query)
response.code < Rack::Utils::SYMBOL_TO_STATUS_CODE[:bad_request]
end
private
def call_api