Skip to content

Commit

Permalink
Add protogetter linter
Browse files Browse the repository at this point in the history
- Linter updates and style fixes.
- Sync `vendor/` for updated dependencies.
- All test variations pass.
  • Loading branch information
bconway committed Oct 21, 2023
1 parent c3fd6a3 commit 4a61d02
Show file tree
Hide file tree
Showing 114 changed files with 2,066 additions and 1,988 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint version
golangci-lint run -E bidichk,durationcheck,errname,exportloopref \
-E forcetypeassert,goconst,godot,goerr113,gofumpt,gosec,nlreturn,prealloc \
-E unconvert,unparam,usestdlibvars --exclude-use-default=false
-E forcetypeassert,godot,goerr113,gofumpt,gosec,nlreturn,prealloc \
-E protogetter,unconvert,unparam,usestdlibvars --exclude-use-default=false

go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck -test ./...
Expand Down
16 changes: 8 additions & 8 deletions build/deploy/atlas/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
atlas-api:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-api
restart: on-failure
ports:
Expand All @@ -22,7 +22,7 @@ services:
- API_LORA_DEV_PROF_ID=00000000-0000-0000-0000-000000000000

atlas-mqtt-ingestor:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-mqtt-ingestor
restart: on-failure
depends_on:
Expand All @@ -34,7 +34,7 @@ services:
- MQTT_INGEST_NSQ_PUB_ADDR=nsqd:4150

atlas-lora-ingestor:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-lora-ingestor
restart: on-failure
depends_on:
Expand All @@ -47,7 +47,7 @@ services:
- LORA_INGEST_NSQ_PUB_ADDR=nsqd:4150

atlas-decoder:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-decoder
restart: on-failure
depends_on:
Expand All @@ -60,7 +60,7 @@ services:
- DECODER_NSQ_LOOKUP_ADDRS=nsqlookupd:4161

atlas-validator:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-validator
restart: on-failure
depends_on:
Expand All @@ -74,7 +74,7 @@ services:
- VALIDATOR_NSQ_LOOKUP_ADDRS=nsqlookupd:4161

atlas-accumulator:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-accumulator
restart: on-failure
environment:
Expand All @@ -84,7 +84,7 @@ services:
- ACCUMULATOR_NSQ_LOOKUP_ADDRS=nsqlookupd:4161

atlas-eventer:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-eventer
restart: on-failure
depends_on:
Expand All @@ -96,7 +96,7 @@ services:
- EVENTER_NSQ_LOOKUP_ADDRS=nsqlookupd:4161

atlas-alerter:
image: ghcr.io/thingspect/atlas:8ef215b5
image: ghcr.io/thingspect/atlas:c3fd6a36
command: atlas-alerter
restart: on-failure
environment:
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/thingspect/atlas

go 1.21.1
go 1.21.3

require (
github.com/NYTimes/gziphandler v1.1.1
Expand All @@ -17,10 +17,10 @@ require (
github.com/redis/go-redis/v9 v9.2.1
github.com/smira/go-statsd v1.3.3
github.com/stretchr/testify v1.8.4
github.com/thingspect/api/go v1.0.14
github.com/thingspect/api/go v1.0.15
go.uber.org/mock v0.3.0
golang.org/x/crypto v0.14.0
google.golang.org/grpc v1.58.3
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
)

Expand All @@ -40,8 +40,8 @@ require (
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -616,8 +616,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/thingspect/api/go v1.0.14 h1:qZOzfr5dHPd8m4fO9yVBH6JN/4ks5C2lEdxcnHIN9rU=
github.com/thingspect/api/go v1.0.14/go.mod h1:Ytxxh/p+gpQmRDDHQLAD0fvggNgIXZLtMCOkpxxLbtQ=
github.com/thingspect/api/go v1.0.15 h1:CV95eLM32+DVa+mw6HallDmmEhUQxGU3JThD4qn19sI=
github.com/thingspect/api/go v1.0.15/go.mod h1:5rsH684TrLl+RPMS4mQP8LEMj69UZj8iDm7yhw2uD2o=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -1108,12 +1108,12 @@ google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZV
google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614GARnxrLsqKREzmNYJACSWWpAWdNMwnD7c2BE=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/genproto v0.0.0-20230202175211-008b39050e57/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/genproto v0.0.0-20231009173412-8bfb1ae86b6c h1:ml3TAUoIIzQUtX88s/icpXCFW9lV5VwsuIuS1htNjKY=
google.golang.org/genproto v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:MugzuwC+GYOxyF0XUGQvsT97bOgWCV7MM1XMc5FZv8E=
google.golang.org/genproto/googleapis/api v0.0.0-20231009173412-8bfb1ae86b6c h1:0RtEmmHjemvUXloH7+RuBSIw7n+GEHMOMY1CkGYnWq4=
google.golang.org/genproto/googleapis/api v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:Wth13BrWMRN/G+guBLupKa6fslcWZv14R0ZKDRkNfY8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI=
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k=
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down Expand Up @@ -1152,8 +1152,8 @@ google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
Expand Down
12 changes: 6 additions & 6 deletions internal/atlas-accumulator/accumulator/accumulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (acc *Accumulator) accumulateMessages() {
metric.Incr("received", nil)
vOut := &message.ValidatorOut{}
err := proto.Unmarshal(msg.Payload(), vOut)
if err != nil || vOut.Point == nil || vOut.Device == nil {
if err != nil || vOut.GetPoint() == nil || vOut.GetDevice() == nil {
msg.Ack()

if !bytes.Equal([]byte{queue.Prime}, msg.Payload()) {
Expand All @@ -38,14 +38,14 @@ func (acc *Accumulator) accumulateMessages() {

// Set up logging fields.
logger := alog.
WithField("traceID", vOut.Point.TraceId).
WithField("orgID", vOut.Device.OrgId).
WithField("uniqID", vOut.Point.UniqId).
WithField("devID", vOut.Device.Id)
WithField("traceID", vOut.GetPoint().GetTraceId()).
WithField("orgID", vOut.GetDevice().GetOrgId()).
WithField("uniqID", vOut.GetPoint().GetUniqId()).
WithField("devID", vOut.GetDevice().GetId())

// Create data point.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
err = acc.dpDAO.Create(ctx, vOut.Point, vOut.Device.OrgId)
err = acc.dpDAO.Create(ctx, vOut.GetPoint(), vOut.GetDevice().GetOrgId())
cancel()
if errors.Is(err, dao.ErrAlreadyExists) {
msg.Ack()
Expand Down
2 changes: 1 addition & 1 deletion internal/atlas-accumulator/accumulator/accumulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestAccumulateMessages(t *testing.T) {

datapointer := NewMockdatapointer(gomock.NewController(t))
datapointer.EXPECT().Create(gomock.Any(), matcher.NewProtoMatcher(
lTest.inp.Point), lTest.inp.Device.OrgId).
lTest.inp.GetPoint()), lTest.inp.GetDevice().GetOrgId()).
DoAndReturn(func(
ctx interface{}, point interface{}, orgID interface{},
) error {
Expand Down
44 changes: 22 additions & 22 deletions internal/atlas-accumulator/test/accumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccumulateMessages(t *testing.T) {
require.NoError(t, err)

createDev, err := globalDevDAO.Create(ctx, random.Device("acc",
createOrg.Id))
createOrg.GetId()))
t.Logf("createDev, err: %+v, %v", createDev, err)
require.NoError(t, err)

Expand Down Expand Up @@ -86,23 +86,23 @@ func TestAccumulateMessages(t *testing.T) {
testTimeout)
defer cancel()

listPoints, err := globalDPDAO.List(ctx, lTest.inp.Device.OrgId,
lTest.inp.Point.UniqId, "", "", lTest.inp.Point.Ts.AsTime(),
lTest.inp.Point.Ts.AsTime().Add(-time.Millisecond))
listPoints, err := globalDPDAO.List(ctx, lTest.inp.GetDevice().GetOrgId(),
lTest.inp.GetPoint().GetUniqId(), "", "", lTest.inp.GetPoint().GetTs().AsTime(),
lTest.inp.GetPoint().GetTs().AsTime().Add(-time.Millisecond))
t.Logf("listPoints, err: %+v, %v", listPoints, err)
require.NoError(t, err)
require.Len(t, listPoints, 1)

// Normalize token.
listPoints[0].Token = lTest.inp.Point.Token
listPoints[0].Token = lTest.inp.GetPoint().GetToken()
// Normalize timestamp.
lTest.inp.Point.Ts = timestamppb.New(
lTest.inp.Point.Ts.AsTime().Truncate(time.Millisecond))
lTest.inp.GetPoint().GetTs().AsTime().Truncate(time.Millisecond))

// Testify does not currently support protobuf equality:
// https://github.com/stretchr/testify/issues/758
if !proto.Equal(lTest.inp.Point, listPoints[0]) {
t.Fatalf("\nExpect: %+v\nActual: %+v", lTest.inp.Point,
if !proto.Equal(lTest.inp.GetPoint(), listPoints[0]) {
t.Fatalf("\nExpect: %+v\nActual: %+v", lTest.inp.GetPoint(),
listPoints[0])
}
})
Expand All @@ -120,7 +120,7 @@ func TestAccumulateMessagesDuplicate(t *testing.T) {
require.NoError(t, err)

createDev, err := globalDevDAO.Create(ctx, random.Device("acc",
createOrg.Id))
createOrg.GetId()))
t.Logf("createDev, err: %+v, %v", createDev, err)
require.NoError(t, err)

Expand All @@ -132,8 +132,8 @@ func TestAccumulateMessagesDuplicate(t *testing.T) {
Token: uuid.NewString(), TraceId: uuid.NewString(),
}, Device: createDev,
}
require.NoError(t, globalDPDAO.Create(ctx, duplicateVOut.Point,
duplicateVOut.Device.OrgId))
require.NoError(t, globalDPDAO.Create(ctx, duplicateVOut.GetPoint(),
duplicateVOut.GetDevice().GetOrgId()))

bVOut, err := proto.Marshal(duplicateVOut)
require.NoError(t, err)
Expand All @@ -145,23 +145,23 @@ func TestAccumulateMessagesDuplicate(t *testing.T) {
ctx, cancel = context.WithTimeout(context.Background(), testTimeout)
defer cancel()

listPoints, err := globalDPDAO.List(ctx, duplicateVOut.Device.OrgId,
duplicateVOut.Point.UniqId, "", "", duplicateVOut.Point.Ts.AsTime(),
duplicateVOut.Point.Ts.AsTime().Add(-time.Millisecond))
listPoints, err := globalDPDAO.List(ctx, duplicateVOut.GetDevice().GetOrgId(),
duplicateVOut.GetPoint().GetUniqId(), "", "", duplicateVOut.GetPoint().GetTs().AsTime(),
duplicateVOut.GetPoint().GetTs().AsTime().Add(-time.Millisecond))
t.Logf("listPoints, err: %+v, %v", listPoints, err)
require.NoError(t, err)
require.Len(t, listPoints, 1)

// Normalize token.
listPoints[0].Token = duplicateVOut.Point.Token
listPoints[0].Token = duplicateVOut.GetPoint().GetToken()
// Normalize timestamp.
duplicateVOut.Point.Ts = timestamppb.New(
duplicateVOut.Point.Ts.AsTime().Truncate(time.Millisecond))
duplicateVOut.GetPoint().GetTs().AsTime().Truncate(time.Millisecond))

// Testify does not currently support protobuf equality:
// https://github.com/stretchr/testify/issues/758
if !proto.Equal(duplicateVOut.Point, listPoints[0]) {
t.Fatalf("\nExpect: %+v\nActual: %+v", duplicateVOut.Point,
if !proto.Equal(duplicateVOut.GetPoint(), listPoints[0]) {
t.Fatalf("\nExpect: %+v\nActual: %+v", duplicateVOut.GetPoint(),
listPoints[0])
}
}
Expand All @@ -177,7 +177,7 @@ func TestAccumulateMessagesError(t *testing.T) {
require.NoError(t, err)

createDev, err := globalDevDAO.Create(ctx, random.Device("acc",
createOrg.Id))
createOrg.GetId()))
t.Logf("createDev, err: %+v, %v", createDev, err)
require.NoError(t, err)

Expand All @@ -200,9 +200,9 @@ func TestAccumulateMessagesError(t *testing.T) {
ctx, cancel = context.WithTimeout(context.Background(), testTimeout)
defer cancel()

listPoints, err := globalDPDAO.List(ctx, invalidVOut.Device.OrgId,
invalidVOut.Point.UniqId, "", "", invalidVOut.Point.Ts.AsTime(),
invalidVOut.Point.Ts.AsTime().Add(-time.Millisecond))
listPoints, err := globalDPDAO.List(ctx, invalidVOut.GetDevice().GetOrgId(),
invalidVOut.GetPoint().GetUniqId(), "", "", invalidVOut.GetPoint().GetTs().AsTime(),
invalidVOut.GetPoint().GetTs().AsTime().Add(-time.Millisecond))
t.Logf("listPoints, err: %+v, %v", listPoints, err)
require.NoError(t, err)
require.Len(t, listPoints, 0)
Expand Down
Loading

0 comments on commit 4a61d02

Please sign in to comment.