Skip to content

Commit

Permalink
refactor: unused event type [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Aug 10, 2024
1 parent ea7e94a commit 50a4b75
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,28 @@ golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a h1:EKiZZXueP9/T68B8Nl0GAx9cjbQnCId0yP3qPMgaaHs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240808171019-573a1156607a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
Expand Down
21 changes: 5 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ import (
"strings"
)

type evtTypeInterests int

const (
evtTypeInterestsCreated evtTypeInterests = iota
evtTypeInterestsUpdated
)

const ceKeyGroupId = "awakarigroupid"
const ceKeyQueriesCompl = "queriescompl"
const ceKeyPublic = "public"
Expand Down Expand Up @@ -102,7 +95,6 @@ func main() {
cfg.Api.Queue.InterestsCreated.Name,
cfg.Api.Queue.InterestsCreated.Subj,
cfg.Api.Queue.InterestsCreated.BatchSize,
evtTypeInterestsCreated,
cfg,
log,
)
Expand All @@ -123,7 +115,6 @@ func main() {
cfg.Api.Queue.InterestsUpdated.Name,
cfg.Api.Queue.InterestsUpdated.Subj,
cfg.Api.Queue.InterestsUpdated.BatchSize,
evtTypeInterestsUpdated,
cfg,
log,
)
Expand All @@ -145,13 +136,12 @@ func consumeQueue(
svcQueue queue.Service,
name, subj string,
batchSize uint32,
typ evtTypeInterests,
cfg config.Config,
log *slog.Logger,
) (err error) {
for {
err = svcQueue.ReceiveMessages(ctx, name, subj, batchSize, func(evts []*pb.CloudEvent) (err error) {
consumeEvents(ctx, svc, evts, typ, cfg, log)
consumeEvents(ctx, svc, evts, cfg, log)
return
})
if err != nil {
Expand All @@ -164,11 +154,10 @@ func consumeEvents(
ctx context.Context,
svc service.Service,
evts []*pb.CloudEvent,
typ evtTypeInterests,
cfg config.Config,
log *slog.Logger,
) {
log.Debug(fmt.Sprintf("consumeEvents(%d, typ=%d))\n", len(evts), typ))
log.Debug(fmt.Sprintf("consumeEvents(%d))\n", len(evts)))
for _, evt := range evts {

interestId := evt.GetTextData()
Expand All @@ -177,7 +166,7 @@ func consumeEvents(
groupId = groupIdAttr.GetCeString()
}
if groupId == "" {
log.Error(fmt.Sprintf("interest %s event type %d: empty group id, skipping", interestId, typ))
log.Error(fmt.Sprintf("interest %s event: empty group id, skipping", interestId))
continue
}

Expand All @@ -187,7 +176,7 @@ func consumeEvents(
actor := interestId + "@" + cfg.Api.ActivityPub.Host
_, _ = svc.SearchAndAdd(ctx, interestId, groupId, actor, 1, model.SearchTypeAccounts)
default:
log.Debug(fmt.Sprintf("interest %s event type %d: public: %t/%t", interestId, typ, publicAttrPresent, publicAttr.GetCeBoolean()))
log.Debug(fmt.Sprintf("interest %s event: public: %t/%t", interestId, publicAttrPresent, publicAttr.GetCeBoolean()))
}

var queries []string
Expand All @@ -196,7 +185,7 @@ func consumeEvents(
}
switch len(queries) {
case 0:
log.Debug(fmt.Sprintf("interest %s event type %d: no queries, skipping the sources discovery", interestId, typ))
log.Debug(fmt.Sprintf("interest %s event: no queries, skipping the sources discovery", interestId))
default:
for _, q := range queries {
_, _ = svc.SearchAndAdd(ctx, interestId, groupId, q, cfg.Api.Mastodon.Search.Limit, model.SearchTypeStatuses)
Expand Down

0 comments on commit 50a4b75

Please sign in to comment.