Skip to content

Commit

Permalink
feat: utilize new daily pub limits
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Jan 26, 2025
1 parent 78f86d9 commit 49394a9
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.4-alpine3.20 AS builder
FROM golang:1.23.5-alpine3.20 AS builder
WORKDIR /go/src/metrics
COPY . .
RUN \
Expand Down
49 changes: 38 additions & 11 deletions api/grpc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type Controller interface {
type controller struct {
svcLimits limits.Service
svc service.Service
pubMin int64
pubMax int64
pubMinHourly int64
pubMinDaily int64
pubMaxHourly int64
pubMaxDaily int64
svcFeeds feeds.Service
svcSites sites.Service
svcTg telegram.Service
Expand All @@ -39,8 +41,10 @@ const limitAutoExpirationThreshold = 15 * time.Minute
func NewController(
svcLimits limits.Service,
svcMetrics service.Service,
pubMin int64,
pubMax int64,
pubMinHourly int64,
pubMinDaily int64,
pubMaxHourly int64,
pubMaxDaily int64,
svcFeeds feeds.Service,
svcSites sites.Service,
svcTg telegram.Service,
Expand All @@ -50,8 +54,10 @@ func NewController(
return controller{
svcLimits: svcLimits,
svc: svcMetrics,
pubMin: pubMin,
pubMax: pubMax,
pubMinHourly: pubMinHourly,
pubMinDaily: pubMinDaily,
pubMaxHourly: pubMaxHourly,
pubMaxDaily: pubMaxDaily,
svcFeeds: svcFeeds,
svcSites: svcSites,
svcTg: svcTg,
Expand All @@ -64,7 +70,8 @@ func (c controller) SetMostReadLimits(ctx context.Context, req *SetMostReadLimit
resp = &SetMostReadLimitsResponse{}
var rateBySrc map[string]float64
if c.svc != nil {
resp.LimitBySource = make(map[string]int64)
resp.HourlyLimitBySource = make(map[string]int64)
resp.DailyLimitBySource = make(map[string]int64)
var rateSum float64
rateSum, err = c.svc.GetRateAverage(ctx, "awk_reader_read_count", "service", "1d")
if err == nil {
Expand Down Expand Up @@ -131,21 +138,41 @@ func (c controller) SetMostReadLimits(ctx context.Context, req *SetMostReadLimit
fmt.Printf("SetMostReadLimits: source %s is sharing the limit of %s, skipping the automatic limit setting\n", srcUrl, userId)
continue
}

var l model.Limit
l, err = c.svcLimits.GetRaw(ctx, groupId, srcUrl, model.SubjectPublishEvents)

// hourly limit
l, err = c.svcLimits.GetRaw(ctx, groupId, srcUrl, model.SubjectPublishHourly)
switch {
case errors.Is(err, limits.ErrNotFound):
fallthrough
case !l.Expires.IsZero() && l.Expires.Before(time.Now().UTC().Add(limitAutoExpirationThreshold)):
l.Count = c.pubMinHourly + int64(float64(c.pubMaxHourly)*rateRel)
l.Expires = time.Now().UTC().Add(limitAutoExpirationDefault)
err = c.svcLimits.Set(ctx, groupId, srcUrl, model.SubjectPublishHourly, l.Count, l.Expires)
if err == nil {
resp.HourlyLimitBySource[srcUrl] = l.Count
}
default:
fmt.Printf("SetMostReadLimits: source %s has a limit that isn't expiring (%s), skipping\n", srcUrl, l.Expires)
}

// daily limit
l, err = c.svcLimits.GetRaw(ctx, groupId, srcUrl, model.SubjectPublishDaily)
switch {
case errors.Is(err, limits.ErrNotFound):
fallthrough
case !l.Expires.IsZero() && l.Expires.Before(time.Now().UTC().Add(limitAutoExpirationThreshold)):
l.Count = c.pubMin + int64(float64(c.pubMax)*rateRel)
l.Count = c.pubMinDaily + int64(float64(c.pubMaxDaily)*rateRel)
l.Expires = time.Now().UTC().Add(limitAutoExpirationDefault)
err = c.svcLimits.Set(ctx, groupId, srcUrl, model.SubjectPublishEvents, l.Count, l.Expires)
err = c.svcLimits.Set(ctx, groupId, srcUrl, model.SubjectPublishDaily, l.Count, l.Expires)
if err == nil {
resp.LimitBySource[srcUrl] = l.Count
resp.DailyLimitBySource[srcUrl] = l.Count
}
default:
fmt.Printf("SetMostReadLimits: source %s has a limit that isn't expiring (%s), skipping\n", srcUrl, l.Expires)
}

err = nil
}
}
Expand Down
6 changes: 4 additions & 2 deletions api/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ func Serve(
controllerAdmin := NewController(
svcLimits,
svcMetrics,
cfg.Limits.Default.User.PublishMessages,
cfg.Limits.Max.User.PublishMessages,
cfg.Limits.Default.User.Publish.Hourly,
cfg.Limits.Default.User.Publish.Daily,
cfg.Limits.Max.User.Publish.Hourly,
cfg.Limits.Max.User.Publish.Daily,
svcSrcFeeds,
svcSrcSites,
svcSrcTg,
Expand Down
3 changes: 2 additions & 1 deletion api/grpc/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ message SetMostReadLimitsRequest {
}

message SetMostReadLimitsResponse {
map<string, int64> limitBySource = 1;
map<string, int64> hourlyLimitBySource = 1;
map<string, int64> dailyLimitBySource = 2;
}
24 changes: 13 additions & 11 deletions api/grpc/subject/subject.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package subject

import (
"fmt"
"github.com/awakari/metrics/model"
"fmt"
"github.com/awakari/metrics/model"
)

func Encode(src model.Subject) (dst Subject, err error) {
switch src {
case model.SubjectInterests:
dst = Subject_Interests
case model.SubjectPublishEvents:
dst = Subject_PublishEvents
default:
err = fmt.Errorf(fmt.Sprintf("invalid subject: %s", src))
}
return
switch src {
case model.SubjectInterests:
dst = Subject_Interests
case model.SubjectPublishHourly:
dst = Subject_PublishHourly
case model.SubjectPublishDaily:
dst = Subject_PublishDaily
default:
err = fmt.Errorf(fmt.Sprintf("invalid subject: %s", src))
}
return
}
3 changes: 2 additions & 1 deletion api/grpc/subject/subject.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ option go_package = "github.com/awakari/metrics/api/grpc/subject";
enum Subject {
Undefined = 0;
Interests = 1;
PublishEvents = 2;
PublishHourly = 2;
PublishDaily = 3;
}
10 changes: 8 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ type LimitsConfig struct {
Default struct {
Groups []string `envconfig:"LIMITS_DEFAULT_GROUPS" default:"" required:"true"`
User struct {
PublishMessages int64 `envconfig:"LIMITS_DEFAULT_USER_PUBLISH_MESSAGES" default:"4" required:"true"`
Publish struct {
Hourly int64 `envconfig:"LIMITS_DEFAULT_USER_PUBLISH_HOURLY" default:"10" required:"true"`
Daily int64 `envconfig:"LIMITS_DEFAULT_USER_PUBLISH_DAILY" default:"100" required:"true"`
}
}
}
Max struct {
User struct {
PublishMessages int64 `envconfig:"LIMITS_MAX_USER_PUBLISH_MESSAGES" default:"1000" required:"true"`
Publish struct {
Hourly int64 `envconfig:"LIMITS_MAX_USER_PUBLISH_HOURLY" default:"3600" required:"true"`
Daily int64 `envconfig:"LIMITS_MAX_USER_PUBLISH_DAILY" default:"86400" required:"true"`
}
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/processout/grpc-go-pool v1.2.1
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.61.0
github.com/prometheus/common v0.62.0
github.com/stretchr/testify v1.10.0
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.36.1
google.golang.org/grpc v1.70.0
google.golang.org/protobuf v1.36.4
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.12.6 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/bytedance/sonic v1.12.7 // indirect
github.com/bytedance/sonic/loader v0.2.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v1.0.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/go-playground/validator/v10 v10.24.0 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Expand All @@ -43,10 +42,10 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.13.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250124145028-65684f501c47 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
61 changes: 30 additions & 31 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bytedance/sonic v1.12.6 h1:/isNmCUF2x3Sh8RAp/4mh4ZGkcFAX/hLrzrK3AvpRzk=
github.com/bytedance/sonic v1.12.6/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q=
github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E=
github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.3 h1:yctD0Q3v2NOGfSWPLPvG2ggA2kV6TS6s4wioyEqssH0=
github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -31,8 +30,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
Expand Down Expand Up @@ -83,8 +82,8 @@ github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
Expand All @@ -105,35 +104,35 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU=
go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/arch v0.13.0 h1:KCkqVVV1kGg0X87TFysjCJ8MxtZEIU4Ja/yXGeoECdA=
golang.org/x/arch v0.13.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d h1:xJJRGY7TJcvIlpSrN3K6LAWgNFUILlO+OMAqtg9aqnw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250124145028-65684f501c47 h1:91mG8dNTpkC0uChJUQ9zCiRqx3GEEFOWaRZ0mI6Oj2I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250124145028-65684f501c47/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
12 changes: 8 additions & 4 deletions helm/metrics/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ spec:
value: "{{ .Values.service.http.port }}"
- name: LIMITS_DEFAULT_GROUPS
value: {{ .Values.limits.default.groups }}
- name: LIMITS_DEFAULT_USER_PUBLISH_MESSAGES
value: "{{ .Values.limits.default.user.publishMessages }}"
- name: LIMITS_MAX_USER_PUBLISH_MESSAGES
value: "{{ .Values.limits.max.user.publishMessages }}"
- name: LIMITS_DEFAULT_USER_PUBLISH_HOURLY
value: "{{ .Values.limits.default.user.publish.hourly }}"
- name: LIMITS_DEFAULT_USER_PUBLISH_DAILY
value: "{{ .Values.limits.default.user.publish.daily }}"
- name: LIMITS_MAX_USER_PUBLISH_HOURLY
value: "{{ .Values.limits.max.user.publish.hourly }}"
- name: LIMITS_MAX_USER_PUBLISH_DAILY
value: "{{ .Values.limits.max.user.publish.daily }}"
- name: LOG_LEVEL
value: "{{ .Values.log.level }}"
- name: API_INTERESTS_URI
Expand Down
10 changes: 7 additions & 3 deletions helm/metrics/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ limits:
# comma-separated list of groups
groups: "default"
user:
publishMessages: 4
publish:
hourly: 10
daily: 100
max:
user:
publishMessages: 3600
publish:
hourly: 3600
daily: 86400
reset:
disabled: false
schedule: "55 * * * *"
schedule: "55 23 * * *"
image: "fullstorydev/grpcurl:v1.9.1-alpine"
args:
- "-plaintext"
Expand Down
6 changes: 4 additions & 2 deletions model/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ type Subject int
const (
SubjectUndefined Subject = iota
SubjectInterests
SubjectPublishEvents
SubjectPublishHourly
SubjectPublishDaily
)

func (s Subject) String() string {
return [...]string{
"SubjectUndefined",
"SubjectInterests",
"SubjectPublishEvents",
"SubjectPublishHourly",
"SubjectPublishDaily",
}[s]
}

0 comments on commit 49394a9

Please sign in to comment.