Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gotimeout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dustin L. Howett
gotimeout
Commits
3eb93ce3
Commit
3eb93ce3
authored
Feb 11, 2015
by
Dustin L. Howett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the StorageAdapter interface functions so they're less generic.
parent
af12bc6a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
expirator.go
expirator.go
+2
-2
legacy.go
legacy.go
+2
-2
storage.go
storage.go
+7
-7
No files found.
expirator.go
View file @
3eb93ce3
...
...
@@ -122,7 +122,7 @@ func NewExpiratorWithStorage(sa StorageAdapter, store ExpirableStore) *Expirator
}
func
(
e
*
Expirator
)
loadExpirations
()
error
{
hm
,
err
:=
e
.
adapter
.
Load
()
hm
,
err
:=
e
.
adapter
.
Load
ExpirationHandles
()
if
err
!=
nil
{
return
err
}
...
...
@@ -142,7 +142,7 @@ func (e *Expirator) saveExpirations() error {
if
e
.
expirationMap
==
nil
{
return
nil
}
err
:=
e
.
adapter
.
Save
(
e
.
expirationMap
)
err
:=
e
.
adapter
.
Save
ExpirationHandles
(
e
.
expirationMap
)
if
err
!=
nil
{
return
err
}
...
...
legacy.go
View file @
3eb93ce3
...
...
@@ -10,8 +10,8 @@ type legacyUpgradingGobFileAdapter struct {
*
GobFileAdapter
}
func
(
a
*
legacyUpgradingGobFileAdapter
)
Load
()
(
*
HandleMap
,
error
)
{
hm
,
err
:=
a
.
GobFileAdapter
.
Load
()
func
(
a
*
legacyUpgradingGobFileAdapter
)
Load
ExpirationHandles
()
(
*
HandleMap
,
error
)
{
hm
,
err
:=
a
.
GobFileAdapter
.
Load
ExpirationHandles
()
if
err
==
nil
{
return
hm
,
err
}
...
...
storage.go
View file @
3eb93ce3
...
...
@@ -7,14 +7,14 @@ import (
// StorageAdapter is the interface through which expiration storage is abstracted.
//
// Save
stores a set of expiration handles, and Load
returns them unharmed.
// Save
ExpirationHandles stores a set of expiration handles, and LoadExpirationHandles
returns them unharmed.
//
// Implementation that care about saving their changes in a timely manner should
// return true from RequiresFlush.
type
StorageAdapter
interface
{
RequiresFlush
()
bool
Save
(
*
HandleMap
)
error
Load
()
(
*
HandleMap
,
error
)
Save
ExpirationHandles
(
*
HandleMap
)
error
Load
ExpirationHandles
()
(
*
HandleMap
,
error
)
}
// GobFileAdapter is a StorageAdapter that saves expiration handles in a file via the encoding/gob package.
...
...
@@ -26,7 +26,7 @@ func (a *GobFileAdapter) RequiresFlush() bool {
return
true
}
func
(
a
*
GobFileAdapter
)
Save
(
hm
*
HandleMap
)
error
{
func
(
a
*
GobFileAdapter
)
Save
ExpirationHandles
(
hm
*
HandleMap
)
error
{
file
,
err
:=
os
.
Create
(
a
.
filename
)
if
err
!=
nil
{
return
err
...
...
@@ -40,7 +40,7 @@ func (a *GobFileAdapter) Save(hm *HandleMap) error {
return
nil
}
func
(
a
*
GobFileAdapter
)
Load
()
(
*
HandleMap
,
error
)
{
func
(
a
*
GobFileAdapter
)
Load
ExpirationHandles
()
(
*
HandleMap
,
error
)
{
file
,
err
:=
os
.
Open
(
a
.
filename
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -66,9 +66,9 @@ func (NoopAdapter) RequiresFlush() bool {
return
false
}
func
(
NoopAdapter
)
Save
(
*
HandleMap
)
error
{
func
(
NoopAdapter
)
Save
ExpirationHandles
(
*
HandleMap
)
error
{
return
nil
}
func
(
NoopAdapter
)
Load
()
(
*
HandleMap
,
error
)
{
func
(
NoopAdapter
)
Load
ExpirationHandles
()
(
*
HandleMap
,
error
)
{
return
nil
,
nil
}
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