Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 4fcb07f

Browse files
committed
live: add ping responder capability for live nodes
1 parent 585d60e commit 4fcb07f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

common/live_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type JobResponseDBCreate struct {
3939
NodeName string `json:"node_name"`
4040
}
4141

42-
// JobResponseDBError holds the structure used when our job queue backend only needs to response with an error field (empty or not)
42+
// JobResponseDBError holds the structure used when our job queue backend only needs to respond with an error field (empty or not)
4343
type JobResponseDBError struct {
4444
Err string `json:"error"`
4545
}

common/memcache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func ConnectCache() (err error) {
8282
}
8383

8484
// DeleteCacheItem deletes the cached item with the given key if it exists
85-
func DeleteCacheItem(cacheKey string) (error) {
85+
func DeleteCacheItem(cacheKey string) error {
8686
err := memCache.Delete(cacheKey)
8787

8888
// We don't care about cache misses

common/postgresql_live.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ func JobQueueCheck() {
222222
}
223223

224224
case "ping":
225-
// TODO: Write a ping responder so we can internally check if live nodes are responding
225+
// This just returns an empty response
226+
var response JobResponseDBError
227+
responsePayload, err = json.Marshal(response)
228+
if err != nil {
229+
log.Printf("%s: error when serialising ping response json: %s", config.Conf.Live.Nodename, err)
230+
responsePayload = []byte(fmt.Sprintf(`{"error": "%s"}`, err))
231+
}
226232

227233
case "query":
228234
if JobQueueDebug > 0 {

0 commit comments

Comments
 (0)