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
5f470b0a
Commit
5f470b0a
authored
3 years ago
by
thijsheijden
Browse files
Options
Downloads
Patches
Plain Diff
Renamed keyvaluedriver to keyvaluestore
parent
8873ba5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/drivers/keyvaluedriver/keyvaluedriver.go
+7
-7
7 additions, 7 deletions
internal/drivers/keyvaluedriver/keyvaluedriver.go
internal/usecases/produce/publishmessage.go
+6
-0
6 additions, 0 deletions
internal/usecases/produce/publishmessage.go
with
13 additions
and
7 deletions
internal/drivers/keyvaluedriver/keyvaluedriver.go
+
7
−
7
View file @
5f470b0a
...
...
@@ -9,18 +9,18 @@ import (
"github.com/go-redis/redis/v8"
)
// KeyValue
Driver
models the redis driver
type
KeyValue
Driver
struct
{
// KeyValue
Store
models the redis driver
type
KeyValue
Store
struct
{
client
*
redis
.
Client
}
// NewRedisDriver creates and returns a redis driver
func
NewRedisDriver
()
*
KeyValue
Driver
{
return
&
KeyValue
Driver
{}
func
NewRedisDriver
()
*
KeyValue
Store
{
return
&
KeyValue
Store
{}
}
// Start starts the redis driver
func
(
d
*
KeyValue
Driver
)
Start
()
{
func
(
d
*
KeyValue
Store
)
Start
()
{
// Grab the redis host and port from environment vars
redisAddress
:=
os
.
Getenv
(
"REDIS_ADDRESS"
)
// redisPassword := os.Getenv("REDIS_PASSWORD")
...
...
@@ -35,12 +35,12 @@ func (d *KeyValueDriver) Start() {
}
// Get retrieves the value from the redis store that belongs to the given key
func
(
d
*
KeyValue
Driver
)
Get
(
key
*
string
)
string
{
func
(
d
*
KeyValue
Store
)
Get
(
key
*
string
)
string
{
return
d
.
client
.
Get
(
context
.
Background
(),
*
key
)
.
Val
()
}
// Set sets the key value pair in the redis store
func
(
d
*
KeyValue
Driver
)
Set
(
key
*
string
,
value
*
string
)
error
{
func
(
d
*
KeyValue
Store
)
Set
(
key
*
string
,
value
*
string
)
error
{
status
:=
d
.
client
.
Set
(
context
.
Background
(),
*
key
,
*
value
,
0
)
return
status
.
Err
()
}
This diff is collapsed.
Click to expand it.
internal/usecases/produce/publishmessage.go
+
6
−
0
View file @
5f470b0a
package
produce
import
(
"fmt"
"query-service/pkg/logger"
"github.com/streadway/amqp"
)
...
...
@@ -9,9 +12,12 @@ func (s *Service) PublishMessage(data *[]byte, sessionID *string) {
// Use the sessionID to query the key value store to get the queue we need to send this message to
clientQueueID
:=
s
.
keyValueStore
.
Get
(
sessionID
)
logger
.
Log
(
fmt
.
Sprintf
(
"Found client queue %s for session %s"
,
clientQueueID
,
*
sessionID
))
// If this client has now disconnected
if
clientQueueID
==
""
{
// TODO: Decide whether to throw away the message or perhaps cache it, for now throw it away
logger
.
Log
(
"No client updater queue ID"
)
return
}
...
...
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