Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reorganise Package Structure #97

Merged
merged 67 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
dc1093c
publisher: log: add tests
turtleDev Sep 2, 2024
a0203e1
worker: test for ack function
turtleDev Sep 3, 2024
bad90fd
worker: tests: remove unused mocks
turtleDev Sep 3, 2024
fb55724
worker: add tests for error cases
turtleDev Sep 3, 2024
873be45
worker: test: use constructor for tests
turtleDev Sep 3, 2024
e78a9d6
app: worker: fix flush always timing out
turtleDev Sep 3, 2024
3699a3a
app: move kafka specific log messages to kafka publisher package
turtleDev Sep 3, 2024
9f37c54
wip: worker metrics test
turtleDev Sep 3, 2024
1612548
worker: add tests against instrumented metrics
turtleDev Sep 4, 2024
cf724d7
worker: rename timeSource to Clock
turtleDev Sep 4, 2024
4e53510
chore: remove client example
turtleDev Sep 4, 2024
5cc9f1a
worker: use idiomatic null device for tests
turtleDev Sep 4, 2024
1bbe539
config: add tests for validation errors
turtleDev Sep 4, 2024
03b8f6b
config: add test for valid configuration
turtleDev Sep 4, 2024
5f4c22b
config: add tests for internal prepare()
turtleDev Sep 4, 2024
8c4f37d
config: add tests for Walk()
turtleDev Sep 4, 2024
5d8a779
config: kafka: add tests for ToConfigMap()
turtleDev Sep 4, 2024
ad765fd
config: kafka: add more tests for config map serializer
turtleDev Sep 4, 2024
1ddad34
config: add tests for internal helper functions
turtleDev Sep 4, 2024
5132317
refactor: extract Clock to a stand alone package
turtleDev Sep 5, 2024
e779dd0
collector: add tests for TimePushed mutation
turtleDev Sep 5, 2024
855968e
serialization: add tests for SerialiseProto
turtleDev Sep 5, 2024
fbc699c
deserialization: add tests for DeserializeFunc
turtleDev Sep 5, 2024
977904e
worker: add test for flush time out
turtleDev Sep 5, 2024
713f7c2
config: refactor ack value names
turtleDev Sep 5, 2024
fa3d4c5
tests: integration e2e tests results in coverage data
turtleDev Sep 5, 2024
527b475
ci: test: fix coverage merge failing
turtleDev Sep 5, 2024
84fabf3
ci: prospective fix for coverdata #1
turtleDev Sep 5, 2024
1d47e97
ci: prospective fix for coverdata #2
turtleDev Sep 5, 2024
af606d4
ci: prospective fix for coverdata #3
turtleDev Sep 5, 2024
810e404
ci: upload test coverage as artifact
turtleDev Sep 5, 2024
b6535f6
ci: refactor Docker build for release and testing
turtleDev Sep 6, 2024
05a09c4
services: grpc: add tests for synchronous event handling
turtleDev Sep 6, 2024
c3d9a03
services: grpc: add tests to cover metric instrumentation
turtleDev Sep 6, 2024
76c4591
services: rest: remove deadcode
turtleDev Sep 6, 2024
f3c6d4e
services: rest: add tests for error reading request body
turtleDev Sep 6, 2024
c63c73f
services: rest: add tests for malformed request body
turtleDev Sep 6, 2024
e9815a3
services: rest: refactor ack handling
turtleDev Sep 6, 2024
56b7e22
services: rest: add tests for different error paths
turtleDev Sep 6, 2024
9a4ad1b
ci: cache image pulls to speed up tests
turtleDev Sep 6, 2024
39aceac
ci: fix docker image caching
turtleDev Sep 6, 2024
75d0807
ci: ignore proto package during tests
turtleDev Sep 6, 2024
aaa0571
ci: remove docker image caching
turtleDev Sep 6, 2024
1038f46
Revert "ci: ignore proto package during tests"
turtleDev Sep 6, 2024
a39cad6
Revert "Revert "ci: ignore proto package during tests""
turtleDev Sep 6, 2024
38b48f5
Revert "Revert "Revert "ci: ignore proto package during tests"""
turtleDev Sep 6, 2024
7f837bf
publisher: log: move test event to root proto package
turtleDev Sep 6, 2024
0856073
ci: blacklist proto package during tests
turtleDev Sep 6, 2024
5ffb846
hack: publisher: log: use single spaced fields
turtleDev Sep 6, 2024
76e52ce
Revert "publisher: log: move test event to root proto package"
turtleDev Sep 6, 2024
98ac6dd
Revert "ci: blacklist proto package during tests"
turtleDev Sep 6, 2024
67797d9
Revert "hack: publisher: log: use single spaced fields"
turtleDev Sep 6, 2024
986bf94
Revert "Revert "hack: publisher: log: use single spaced fields""
turtleDev Sep 6, 2024
9672b13
ci: ignore proto folders when computing coverage
turtleDev Sep 6, 2024
a727bd7
hack: publisher: log: use double spaced fields
turtleDev Sep 6, 2024
f01cc07
ci: fix coverage data merge
turtleDev Sep 6, 2024
9ec931c
ci: fix cover merge resulting in empty coverage file
turtleDev Sep 6, 2024
d459c90
publish: kinesis: add tests for stream's existence check
turtleDev Sep 7, 2024
970bdcc
misc: improve test case description
turtleDev Sep 7, 2024
f78453a
publisher: kinesis: add tests for hitting rate limits and quotas
turtleDev Sep 7, 2024
e6fa9a1
publisher: kinesis: refactor tests
turtleDev Sep 9, 2024
c6a037a
hygiene: reorganise package structure
turtleDev Sep 9, 2024
d5309e5
refactor: merge serialization and deserialization pkg into serde
turtleDev Sep 9, 2024
bd14ba4
docs: fix broken dashboard link
turtleDev Sep 9, 2024
c32b74d
serde: test: fix broken references
turtleDev Sep 9, 2024
939727d
refactor: integrate middleware package into server/rest
turtleDev Sep 9, 2024
ada541d
Merge branch 'main' into reorg
turtleDev Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/pkg/logger"
)

// Run the server
Expand Down
10 changes: 5 additions & 5 deletions app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"syscall"
"time"

"github.com/raystack/raccoon/collector"
"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/metrics"
"github.com/raystack/raccoon/core/collector"
"github.com/raystack/raccoon/core/worker"
"github.com/raystack/raccoon/pkg/logger"
"github.com/raystack/raccoon/pkg/metrics"
"github.com/raystack/raccoon/publisher"
"github.com/raystack/raccoon/publisher/kafka"
"github.com/raystack/raccoon/publisher/kinesis"
logpub "github.com/raystack/raccoon/publisher/log"
"github.com/raystack/raccoon/publisher/pubsub"
"github.com/raystack/raccoon/services"
"github.com/raystack/raccoon/worker"
services "github.com/raystack/raccoon/server"

pubsubsdk "cloud.google.com/go/pubsub"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
Expand Down
6 changes: 2 additions & 4 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (

"github.com/raystack/raccoon/app"
"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/metrics"
"github.com/raystack/raccoon/middleware"
"github.com/raystack/raccoon/pkg/logger"
"github.com/raystack/raccoon/pkg/metrics"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
Expand All @@ -24,7 +23,6 @@ func serverCommand() *cobra.Command {
if err != nil {
return err
}
middleware.Load()
metrics.Setup()
defer metrics.Close()
logger.SetLevel(config.Log.Level)
Expand Down
2 changes: 1 addition & 1 deletion collector/collector.go → core/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/raystack/raccoon/identification"
"github.com/raystack/raccoon/core/identification"
pb "github.com/raystack/raccoon/proto"
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion collector/service.go → core/collector/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package collector
import (
"context"

"github.com/raystack/raccoon/clock"
"github.com/raystack/raccoon/pkg/clock"
)

type ChannelCollector struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/raystack/raccoon/clock"
"github.com/raystack/raccoon/pkg/clock"
"github.com/stretchr/testify/assert"
)

Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion deserialization/json.go → core/serde/json.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package deserialization
package serde

import "encoding/json"

func DeserializeJSON(b []byte, i interface{}) error {
return json.Unmarshal(b, i)
}

func SerializeJSON(m interface{}) ([]byte, error) {
return json.Marshal(m)
}
34 changes: 33 additions & 1 deletion serialization/json_test.go → core/serde/json_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package serialization
package serde

import (
"reflect"
Expand All @@ -7,6 +7,38 @@ import (
pb "github.com/raystack/raccoon/proto"
)

func TestJSONDeserializer_Deserialize(t *testing.T) {
type args struct {
b []byte
i interface{}
}
tests := []struct {
name string
j DeserializeFunc
args args
wantErr bool
}{
{
name: "Use JSON Deserializer",
j: DeserializeJSON,
args: args{
b: []byte(`{"A": "a"}`),
i: &struct {
A string
}{},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.j(tt.args.b, tt.args.i); (err != nil) != tt.wantErr {
t.Errorf("JSONDeserializer.Deserialize() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestJSONSerializer_Serialize(t *testing.T) {
type args struct {
m interface{}
Expand Down
10 changes: 9 additions & 1 deletion serialization/proto.go → core/serde/proto.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package serialization
package serde

import (
"errors"
Expand All @@ -17,3 +17,11 @@ func SerializeProto(m interface{}) ([]byte, error) {
}
return proto.Marshal(msg)
}

func DeserializeProto(b []byte, i interface{}) error {
msg, ok := i.(proto.Message)
if !ok {
return ErrInvalidProtoMessage
}
return proto.Unmarshal(b, msg)
}
16 changes: 15 additions & 1 deletion deserialization/proto_test.go → core/serde/proto_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package deserialization
package serde

import (
"testing"

"github.com/alecthomas/assert"
pb "github.com/raystack/raccoon/proto"
)

Expand Down Expand Up @@ -44,3 +45,16 @@ func TestProtoDeserilizer_Deserialize(t *testing.T) {
})
}
}

func TestSerialiseProto(t *testing.T) {
t.Run("should return an error if argument is a non-protobuf message", func(t *testing.T) {
arg := struct{}{}
_, err := SerializeProto(arg)
assert.Equal(t, err, ErrInvalidProtoMessage)
})
t.Run("should serialize a proto message", func(t *testing.T) {
v := &pb.SendEventRequest{}
_, err := SerializeProto(v)
assert.Nil(t, err)
})
}
5 changes: 5 additions & 0 deletions core/serde/serde.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package serde

type DeserializeFunc func(b []byte, i interface{}) error

type SerializeFunc func(m interface{}) ([]byte, error)
2 changes: 1 addition & 1 deletion worker/init_test.go → core/worker/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"testing"

"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/pkg/logger"
)

func TestMain(t *testing.M) {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions worker/worker.go → core/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"sync"
"time"

"github.com/raystack/raccoon/clock"
"github.com/raystack/raccoon/collector"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/metrics"
"github.com/raystack/raccoon/core/collector"
"github.com/raystack/raccoon/pkg/clock"
"github.com/raystack/raccoon/pkg/logger"
"github.com/raystack/raccoon/pkg/metrics"
pb "github.com/raystack/raccoon/proto"
"github.com/raystack/raccoon/publisher"
)
Expand Down
8 changes: 4 additions & 4 deletions worker/worker_test.go → core/worker/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"
"time"

"github.com/raystack/raccoon/clock"
"github.com/raystack/raccoon/collector"
"github.com/raystack/raccoon/identification"
"github.com/raystack/raccoon/metrics"
"github.com/raystack/raccoon/core/collector"
"github.com/raystack/raccoon/core/identification"
"github.com/raystack/raccoon/pkg/clock"
"github.com/raystack/raccoon/pkg/metrics"
pb "github.com/raystack/raccoon/proto"
"github.com/raystack/raccoon/publisher"
"github.com/stretchr/testify/assert"
Expand Down
3 changes: 0 additions & 3 deletions deserialization/deserializer.go

This file was deleted.

35 changes: 0 additions & 35 deletions deserialization/json_test.go

This file was deleted.

19 changes: 0 additions & 19 deletions deserialization/proto.go

This file was deleted.

2 changes: 1 addition & 1 deletion docs/docs/guides/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Raccoon provides fine-grained metrics that denote latency. That gives clues as t

### Dashboard

There is a pre-built [grafana dashboard](https://github.com/raystack/raccoon/tree/dashboards/raccoon.json) available with support for Prometheus data source.
There is a pre-built [grafana dashboard](https://github.com/raystack/raccoon/blob/main/grafana.json) available with support for Prometheus data source.

If you're running the statsd + telegraf setup, you can configure telegraf to push metrics to Prometheus.

4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.4
require (
cloud.google.com/go/pubsub v1.38.0
github.com/MakeNowJust/heredoc v1.0.0
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
github.com/aws/aws-sdk-go-v2 v1.27.2
github.com/aws/aws-sdk-go-v2/config v1.27.18
github.com/aws/aws-sdk-go-v2/service/kinesis v1.27.10
Expand Down Expand Up @@ -35,6 +36,8 @@ require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
github.com/alecthomas/chroma v0.8.2 // indirect
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.18 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 // indirect
Expand Down Expand Up @@ -92,6 +95,7 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/progressbar/v3 v3.8.5 // indirect
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.16.0 // indirect
Expand Down
File renamed without changes.
31 changes: 0 additions & 31 deletions middleware/cors.go

This file was deleted.

11 changes: 0 additions & 11 deletions middleware/util.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion metrics/metrics.go → pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/pkg/logger"
)

var instrument MetricInstrument = voidInstrument{}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion metrics/prometheus.go → pkg/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/pkg/logger"
"github.com/spf13/cast"
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion metrics/statsd.go → pkg/metrics/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/raystack/raccoon/config"
"github.com/raystack/raccoon/logger"
"github.com/raystack/raccoon/pkg/logger"
client "gopkg.in/alexcesaro/statsd.v2"
)

Expand Down
Loading
Loading