Skip to content

Commit 1ca0b49

Browse files
authored
Merge pull request #282 from porters-xyz/develop
A few fixes needing to be pushed to prod
2 parents 6d203f7 + 8aef6d5 commit 1ca0b49

39 files changed

+563
-261
lines changed

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ services:
7575
- porters-redis:/data
7676

7777
kit:
78-
image: ghcr.io/pokt-network/pocket-gateway-server:0.1.0-BETA
78+
image: ghcr.io/pokt-network/pocket-gateway-server:0.3.0
7979
volumes:
8080
- ./.env:/app/.env
8181
ports:

gateway/common/prometheus.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
TENANT = "tenant"
1515
QUEUE = "queue"
1616
STAGE = "stage"
17+
RATE_LIMIT = "rateLimit"
1718
)
1819

1920
var (
@@ -30,4 +31,8 @@ var (
3031
Help: "Shows how much the proxy process is adding to request",
3132
Buckets: prometheus.ExponentialBucketsRange(float64(10 * time.Millisecond), float64(20 * time.Second), 10),
3233
}, []string{STAGE})
34+
RateLimitGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
35+
Name: "gateway_rate_limit_hit",
36+
Help: "Shows rate limits hit on a gauge, resets to 0 when resolved",
37+
}, []string{APP, TENANT, RATE_LIMIT})
3338
)

gateway/common/tasks.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"time"
88
)
99

10-
// TODO make it "pluggable" so different types of tasks can operate off queue
11-
1210
type Runnable interface {
1311
error
1412
Run()
@@ -57,7 +55,6 @@ func GetTaskQueue() *TaskQueue {
5755
return qInst
5856
}
5957

60-
// TODO include workers to clear out error channel
6158
func (q *TaskQueue) SetupWorkers() {
6259
numWorkers := GetConfigInt(NUM_WORKERS)
6360
for i := 0; i < numWorkers; i++ {
@@ -117,7 +114,6 @@ func worker(q *TaskQueue) {
117114
}
118115
}
119116

120-
// TODO do more than log
121117
func errWorker(q *TaskQueue) {
122118
for err := range q.errors {
123119
log.Error("error encountered", "err", err)
@@ -129,7 +125,6 @@ func delayWorker(q *TaskQueue) {
129125
for i:=len(q.delayed); i>0; i-- {
130126
task := <- q.delayed
131127
if q.closed {
132-
// TODO log delayed tasks details for cleanup
133128
q.ReportError(errors.New("Shutting down"))
134129
} else if task.Ready() {
135130
q.Add(task)
@@ -141,6 +136,13 @@ func delayWorker(q *TaskQueue) {
141136
time.Sleep(1 * time.Second)
142137
}
143138

139+
func NewSimpleTask(run func()) *SimpleTask {
140+
return &SimpleTask{
141+
run: run,
142+
runtime: time.Now(),
143+
}
144+
}
145+
144146
// SimpleTask can be extended if needed
145147
func (t *SimpleTask) Run() {
146148
t.run()

gateway/common/tasks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestTask(t *testing.T) {
2424
}
2525
}
2626

27-
// TODO use this test to figure out the right blend
27+
// this test can be tweaked to figure out the right blend
2828
// combining is meant to compact multiple updates to redis into one
2929
// rather than incr + incr + incr just do incrBy 3
3030
// This costs a bit of compute and complicates the job queue

0 commit comments

Comments
 (0)