Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
edc1c9e3
Commit
edc1c9e3
authored
3 years ago
by
thijsheijden
Browse files
Options
Downloads
Patches
Plain Diff
Updated keyvaluedriver and its mock
parent
ec0795ab
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/drivers/keyvaluedriver/keyvaluedriver.go
+4
-5
4 additions, 5 deletions
internal/drivers/keyvaluedriver/keyvaluedriver.go
internal/drivers/keyvaluedriver/mock/mockkeyvaluedriver.go
+5
-5
5 additions, 5 deletions
internal/drivers/keyvaluedriver/mock/mockkeyvaluedriver.go
with
9 additions
and
10 deletions
internal/drivers/keyvaluedriver/keyvaluedriver.go
+
4
−
5
View file @
edc1c9e3
...
@@ -35,13 +35,12 @@ func (d *KeyValueDriver) Start() {
...
@@ -35,13 +35,12 @@ func (d *KeyValueDriver) Start() {
}
}
// Get retrieves the value from the redis store that belongs to the given key
// Get retrieves the value from the redis store that belongs to the given key
func
(
d
*
KeyValueDriver
)
Get
(
key
*
string
)
*
string
{
func
(
d
*
KeyValueDriver
)
Get
(
key
*
string
)
string
{
value
:=
d
.
client
.
Get
(
context
.
Background
(),
*
key
)
.
Val
()
return
d
.
client
.
Get
(
context
.
Background
(),
*
key
)
.
Val
()
return
&
value
}
}
// Set sets the key value pair in the redis store
// Set sets the key value pair in the redis store
func
(
d
*
KeyValueDriver
)
Set
(
key
*
string
,
value
interface
{}
)
error
{
func
(
d
*
KeyValueDriver
)
Set
(
key
*
string
,
value
*
string
)
error
{
status
:=
d
.
client
.
Set
(
context
.
Background
(),
*
key
,
value
,
0
)
status
:=
d
.
client
.
Set
(
context
.
Background
(),
*
key
,
*
value
,
0
)
return
status
.
Err
()
return
status
.
Err
()
}
}
This diff is collapsed.
Click to expand it.
internal/drivers/keyvaluedriver/mock/mockkeyvaluedriver.go
+
5
−
5
View file @
edc1c9e3
...
@@ -2,23 +2,23 @@ package mockkeyvaluedriver
...
@@ -2,23 +2,23 @@ package mockkeyvaluedriver
// A KeyValueStore implements methods to set key-value data (mock)
// A KeyValueStore implements methods to set key-value data (mock)
type
KeyValueStore
struct
{
type
KeyValueStore
struct
{
data
map
[
string
]
interface
{}
data
map
[
string
]
string
}
}
// CreateKeyValueStore creates a key value store driver (mock)
// CreateKeyValueStore creates a key value store driver (mock)
func
CreateKeyValueStore
()
*
KeyValueStore
{
func
CreateKeyValueStore
()
*
KeyValueStore
{
return
&
KeyValueStore
{
return
&
KeyValueStore
{
data
:
make
(
map
[
string
]
interface
{}
),
data
:
make
(
map
[
string
]
string
),
}
}
}
}
// Set sets a key to a value in the key value store. Expects a non-pointer as value. (mock)
// Set sets a key to a value in the key value store. Expects a non-pointer as value. (mock)
func
(
kvs
*
KeyValueStore
)
Set
(
key
*
string
,
value
interface
{}
)
error
{
func
(
kvs
*
KeyValueStore
)
Set
(
key
*
string
,
value
*
string
)
error
{
kvs
.
data
[
*
key
]
=
value
kvs
.
data
[
*
key
]
=
*
value
return
nil
return
nil
}
}
// Get gets the value for the supplied key from the key value store (mock)
// Get gets the value for the supplied key from the key value store (mock)
func
(
kvs
*
KeyValueStore
)
Get
(
key
*
string
)
interface
{}
{
func
(
kvs
*
KeyValueStore
)
Get
(
key
*
string
)
string
{
return
kvs
.
data
[
*
key
]
return
kvs
.
data
[
*
key
]
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment