Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_handler.rb « handler « email « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 19826138075671c5d8717abdf522a55c76d62d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Gitlab
  module Email
    module Handler
      class BaseHandler
        attr_reader :mail, :mail_key

        HANDLER_ACTION_BASE_REGEX ||= /(?<project_slug>.+)-(?<project_id>\d+)/

        def initialize(mail, mail_key)
          @mail = mail
          @mail_key = mail_key
        end

        def can_handle?
          raise NotImplementedError
        end

        def execute
          raise NotImplementedError
        end

        def metrics_params
          { handler: self.class.name }
        end

        # 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
      end
    end
  end
end