2018-08-23 05:22:23 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-21 12:40:08 -04:00
|
|
|
module Gitlab
|
|
|
|
module Email
|
|
|
|
module Handler
|
|
|
|
class BaseHandler
|
|
|
|
attr_reader :mail, :mail_key
|
|
|
|
|
2019-01-02 15:41:28 -05:00
|
|
|
HANDLER_ACTION_BASE_REGEX ||= /(?<project_slug>.+)-(?<project_id>\d+)/.freeze
|
|
|
|
|
2016-05-21 12:40:08 -04:00
|
|
|
def initialize(mail, mail_key)
|
|
|
|
@mail = mail
|
|
|
|
@mail_key = mail_key
|
|
|
|
end
|
|
|
|
|
2018-12-20 12:15:31 -05:00
|
|
|
def can_handle?
|
2016-05-21 12:40:08 -04:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-10-12 13:07:36 -04:00
|
|
|
def execute
|
2016-05-21 12:40:08 -04:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2017-04-21 11:11:21 -04:00
|
|
|
|
|
|
|
def metrics_params
|
|
|
|
{ handler: self.class.name }
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
# Each handler should use it's own metric event. Otherwise there
|
|
|
|
# is a possibility that within the same Sidekiq process, that same
|
|
|
|
# event with different metrics_params will cause Prometheus to
|
|
|
|
# throw an error
|
|
|
|
def metrics_event
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-05-21 12:40:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|