Class: Gitlab::Checks::PostPushMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/checks/post_push_message.rb

Direct Known Subclasses

ProjectCreated, ProjectMoved

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, user, protocol) ⇒ PostPushMessage

Returns a new instance of PostPushMessage.


6
7
8
9
10
# File 'lib/gitlab/checks/post_push_message.rb', line 6

def initialize(repository, user, protocol)
  @repository = repository
  @user = user
  @protocol = protocol
end

Class Method Details

.fetch_message(user_id, project_id) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/checks/post_push_message.rb', line 12

def self.fetch_message(user_id, project_id)
  key = message_key(user_id, project_id)

  Gitlab::Redis::SharedState.with do |redis|
    message = redis.get(key)
    redis.del(key)
    message
  end
end

Instance Method Details

#add_messageObject


22
23
24
25
26
27
28
29
# File 'lib/gitlab/checks/post_push_message.rb', line 22

def add_message
  return unless user.present? && project.present?

  Gitlab::Redis::SharedState.with do |redis|
    key = self.class.message_key(user.id, project.id)
    redis.setex(key, 5.minutes, message)
  end
end

#messageObject

Raises:

  • (NotImplementedError)

31
32
33
# File 'lib/gitlab/checks/post_push_message.rb', line 31

def message
  raise NotImplementedError
end