Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
2b7d759a
Commit
2b7d759a
authored
Dec 20, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add with_lease to session [ci skip]
parent
e9c14918
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
8 deletions
+32
-8
lib/mattermost/session.rb
lib/mattermost/session.rb
+32
-8
No files found.
lib/mattermost/session.rb
View file @
2b7d759a
...
...
@@ -26,6 +26,8 @@ module Mattermost
include
Doorkeeper
::
Helpers
::
Controller
include
HTTParty
LEASE_TIMEOUT
=
60
base_uri
Settings
.
mattermost
.
host
attr_accessor
:current_resource_owner
,
:token
...
...
@@ -35,14 +37,16 @@ module Mattermost
end
def
with_session
raise
NoSessionError
unless
create
begin
yield
self
rescue
Errno
::
ECONNREFUSED
raise
NoSessionError
ensure
destroy
with_lease
do
raise
NoSessionError
unless
create
begin
yield
self
rescue
Errno
::
ECONNREFUSED
raise
NoSessionError
ensure
destroy
end
end
end
...
...
@@ -130,5 +134,25 @@ module Mattermost
response
.
headers
[
'token'
]
end
end
def
with_lease
lease_uuid
=
lease_try_obtain
raise
NoSessionError
unless
lease_uuid
begin
yield
ensure
Gitlab
::
ExclusiveLease
.
cancel
(
lease_key
,
lease_uuid
)
end
end
def
lease_key
"mattermost:session"
end
def
lease_try_obtain
lease
=
::
Gitlab
::
ExclusiveLease
.
new
(
lease_key
,
timeout:
LEASE_TIMEOUT
)
lease
.
try_obtain
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment