Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-datastore
Commits
edbdfb8f
Commit
edbdfb8f
authored
Dec 26, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delayed: export datastructure type
That way, we can return it directly.
parent
27c83074
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
delayed/delayed.go
delayed/delayed.go
+22
-11
No files found.
delayed/delayed.go
View file @
edbdfb8f
...
...
@@ -9,50 +9,61 @@ import (
)
// New returns a new delayed datastore.
func
New
(
ds
ds
.
Datastore
,
delay
delay
.
D
)
ds
.
Datastore
{
return
&
d
elayed
{
ds
:
ds
,
delay
:
delay
}
func
New
(
ds
ds
.
Datastore
,
delay
delay
.
D
)
*
Delayed
{
return
&
D
elayed
{
ds
:
ds
,
delay
:
delay
}
}
type
delayed
struct
{
// Delayed is an adapter that delays operations on the inner datastore.
type
Delayed
struct
{
ds
ds
.
Datastore
delay
delay
.
D
}
func
(
dds
*
delayed
)
Put
(
key
ds
.
Key
,
value
[]
byte
)
(
err
error
)
{
var
_
ds
.
Batching
=
(
*
Delayed
)(
nil
)
// Put implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
Put
(
key
ds
.
Key
,
value
[]
byte
)
(
err
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
Put
(
key
,
value
)
}
func
(
dds
*
delayed
)
Get
(
key
ds
.
Key
)
(
value
[]
byte
,
err
error
)
{
// Get implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
Get
(
key
ds
.
Key
)
(
value
[]
byte
,
err
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
Get
(
key
)
}
func
(
dds
*
delayed
)
Has
(
key
ds
.
Key
)
(
exists
bool
,
err
error
)
{
// Has implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
Has
(
key
ds
.
Key
)
(
exists
bool
,
err
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
Has
(
key
)
}
func
(
dds
*
delayed
)
GetSize
(
key
ds
.
Key
)
(
size
int
,
err
error
)
{
// GetSize implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
GetSize
(
key
ds
.
Key
)
(
size
int
,
err
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
GetSize
(
key
)
}
func
(
dds
*
delayed
)
Delete
(
key
ds
.
Key
)
(
err
error
)
{
// Delete implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
Delete
(
key
ds
.
Key
)
(
err
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
Delete
(
key
)
}
func
(
dds
*
delayed
)
Query
(
q
dsq
.
Query
)
(
dsq
.
Results
,
error
)
{
// Query implements the ds.Datastore interface.
func
(
dds
*
Delayed
)
Query
(
q
dsq
.
Query
)
(
dsq
.
Results
,
error
)
{
dds
.
delay
.
Wait
()
return
dds
.
ds
.
Query
(
q
)
}
func
(
dds
*
delayed
)
Batch
()
(
ds
.
Batch
,
error
)
{
// Batch implements the ds.Batching interface.
func
(
dds
*
Delayed
)
Batch
()
(
ds
.
Batch
,
error
)
{
return
ds
.
NewBasicBatch
(
dds
),
nil
}
func
(
dds
*
delayed
)
DiskUsage
()
(
uint64
,
error
)
{
// DiskUsage implements the ds.PersistentDatastore interface.
func
(
dds
*
Delayed
)
DiskUsage
()
(
uint64
,
error
)
{
dds
.
delay
.
Wait
()
return
ds
.
DiskUsage
(
dds
.
ds
)
}
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