debian-mirror-gitlab/lib/gitlab/email/handler/base_handler.rb

39 lines
902 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module Gitlab
module Email
module Handler
class BaseHandler
attr_reader :mail, :mail_key
2019-02-15 15:39:39 +05:30
HANDLER_ACTION_BASE_REGEX ||= /(?<project_slug>.+)-(?<project_id>\d+)/.freeze
2016-09-13 17:45:13 +05:30
def initialize(mail, mail_key)
@mail = mail
@mail_key = mail_key
end
2019-02-15 15:39:39 +05:30
def can_handle?
2016-09-13 17:45:13 +05:30
raise NotImplementedError
end
2017-08-17 22:00:37 +05:30
def execute
2016-09-13 17:45:13 +05:30
raise NotImplementedError
end
2017-08-17 22:00:37 +05:30
def metrics_params
{ handler: self.class.name }
2016-09-13 17:45:13 +05:30
end
2019-12-04 20:38:33 +05:30
# 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-09-13 17:45:13 +05:30
end
end
end
end