Skip to content

Commit

Permalink
lint protos + buf configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
chicco785 committed Oct 4, 2023
1 parent 1585608 commit be08b46
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 281 deletions.
416 changes: 226 additions & 190 deletions pkg/data/v1/data.pb.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pkg/data/v1/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"google.golang.org/protobuf/proto"
)

func generateData(dataType int, value uint64, time int64) *Data {
func generateData(dataType int, value uint64, timestamp int64) *Data {

Check failure on line 13 in pkg/data/v1/data_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

`generateData` - `value` always receives `uint64(0)` (`0`) (unparam)
return &Data{
DataType: DataType(dataType),
Value: &value,
MeasuredAt: time,
MeasuredAt: timestamp,
}
}

Expand All @@ -23,7 +23,7 @@ func generateDataSet(producerId string, data map[string]*Data) *DataSet {
}

func TestData(t *testing.T) {
test := generateData(rand.Intn(42), *new(uint64), time.Now().UnixNano())
test := generateData(rand.Intn(42), uint64(0), time.Now().UnixNano())
buf, err := proto.Marshal(test)
assert.NoError(t, err)
data := &Data{}
Expand All @@ -37,7 +37,7 @@ func TestData(t *testing.T) {
func TestDataSet(t *testing.T) {
dataMap := map[string]*Data{}
for k := 0; k < 42; k++ {
dataMap[uuid.New().String()] = generateData(k, *new(uint64), time.Now().UnixNano())
dataMap[uuid.New().String()] = generateData(k, uint64(0), time.Now().UnixNano())
}
test := generateDataSet("myDataSet", dataMap)
buf, err := proto.Marshal(test)
Expand All @@ -50,7 +50,7 @@ func TestDataSet(t *testing.T) {
}

func BenchmarkTestData(b *testing.B) {
test := generateData(rand.Intn(42), *new(uint64), time.Now().UnixNano())
test := generateData(rand.Intn(42), uint64(0), time.Now().UnixNano())
for i := 0; i < b.N; i++ {
buf, _ := proto.Marshal(test)
conf := &Data{}
Expand All @@ -61,7 +61,7 @@ func BenchmarkTestData(b *testing.B) {
func BenchmarkTestDataSet(b *testing.B) {
dataMap := map[string]*Data{}
for k := 0; k < 42; k++ {
dataMap[uuid.New().String()] = generateData(k, *new(uint64), time.Now().UnixNano())
dataMap[uuid.New().String()] = generateData(k, uint64(0), time.Now().UnixNano())
}
test := generateDataSet("myDataSet", dataMap)
for i := 0; i < b.N; i++ {
Expand Down
84 changes: 50 additions & 34 deletions pkg/task/v1/task.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: v1
lint:
use:
- MINIMAL
- ENUM_PASCAL_CASE
- ENUM_VALUE_UPPER_SNAKE_CASE
- MESSAGE_PASCAL_CASE
- ONEOF_LOWER_SNAKE_CASE
- PACKAGE_LOWER_SNAKE_CASE
- RPC_PASCAL_CASE
- SERVICE_PASCAL_CASE
- PACKAGE_SAME_CSHARP_NAMESPACE
- PACKAGE_SAME_GO_PACKAGE
- PACKAGE_SAME_JAVA_MULTIPLE_FILES
- PACKAGE_SAME_JAVA_PACKAGE
- PACKAGE_SAME_PHP_NAMESPACE
- PACKAGE_SAME_RUBY_PACKAGE
- PACKAGE_SAME_SWIFT_PREFIX
- ENUM_FIRST_VALUE_ZERO
- ENUM_NO_ALLOW_ALIAS
- IMPORT_NO_WEAK
- IMPORT_NO_PUBLIC
- IMPORT_USED
90 changes: 46 additions & 44 deletions proto/data/v1/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,53 @@ package data.v1;
option go_package = "./data";

enum DataType {
ACTIVE_POWER = 0;
ANGLE = 1;
AUTOMATIC = 2;
BOOLEAN = 3; //DISCRETE (True or False)
CONFIG_CHANGE = 4; //DISCRETE (True or False)
CURRENT_SEQUENCE_NEGATIVE = 5; //PHASOR
CURRENT_SEQUENCE_POSITIVE = 6; //PHASOR
CURRENT_SEQUENCE_ZERO = 7; //PHASOR
DATA_ERROR = 8; //DISCRETE (True or False)
DATA_MODIFIED = 9; //DISCRETE (True or False)
DATA_SORTING = 10; //DISCRETE
ENERGY = 11; //ANALOG
FREQUENCY = 12; //ANALOG
LINE_CURRENT = 13; //ANALOG
LINE_TO_LINE_VOLTAGE = 14; //ANALOG
LOCAL_OPERATION = 15; //DISCRETE
OPERATION_COUNT = 16; //DISCRETE
PACKET_LATENCY = 17; //ANALOG
PHASE_VOLTAGE = 18; //ANALOG
PHASOR_CURRENT = 19; //PHASOR
PHASOR_VOLTAGE = 20; //PHASOR
PMU_SYNC = 21; //DISCRETE (True or False)
PMU_TIME_QUALITY = 22; //DISCRETE
PMU_TRIGGER_DETECTED = 23; //DISCRETE (True or False)
POWER = 24; //ANALOG
POWER_FACTOR = 25; //ANALOG
PRESSURE = 26; //ANALOG
RATE_OF_CHANGE_OF_FREQUENCY = 27; //ANALOG
REACTIVE_POWER = 28; //ANALOG
SWITCH_POSITION = 29; //DISCRETE (True or False)
TAP_POSITION = 30; //DISCRETE
TEMPERATURE = 31; //ANALOG
THREE_PHASE_ACTIVE_POWER = 32; //ANALOG
THREE_PHASE_CURRENT = 33; //ANALOG
THREE_PHASE_POWER = 34; //ANALOG
THREE_PHASE_POWER_FACTOR = 35; //ANALOG
THREE_PHASE_REACTIVE_POWER = 36; //ANALOG
TRIGGER_REASON = 37; //DISCRETE
UNLOCKED_TIME = 38; //DISCRETE
VOLTAGE_SEQUENCE_NEGATIVE = 39; //PHASOR
VOLTAGE_SEQUENCE_POSITIVE = 40; //PHASOR
VOLTAGE_SEQUENCE_ZERO = 41; //PHASOR
DISCRETE = 42; //DISCRETE
DATA_TYPE_UNSPECIFIED = 0;
DATA_TYPE_ACTIVE_POWER = 1;
DATA_TYPE_ANGLE = 2;
DATA_TYPE_AUTOMATIC = 3;
DATA_TYPE_BOOLEAN = 4; //DISCRETE (True or False)
DATA_TYPE_CONFIG_CHANGE = 5; //DISCRETE (True or False)
DATA_TYPE_CURRENT_SEQUENCE_NEGATIVE = 6; //PHASOR
DATA_TYPE_CURRENT_SEQUENCE_POSITIVE = 7; //PHASOR
DATA_TYPE_CURRENT_SEQUENCE_ZERO = 8; //PHASOR
DATA_TYPE_DATA_ERROR = 9; //DISCRETE (True or False)
DATA_TYPE_DATA_MODIFIED = 10; //DISCRETE (True or False)
DATA_TYPE_DATA_SORTING = 11; //DISCRETE
DATA_TYPE_ENERGY = 12; //ANALOG
DATA_TYPE_FREQUENCY = 13; //ANALOG
DATA_TYPE_LINE_CURRENT = 14; //ANALOG
DATA_TYPE_LINE_TO_LINE_VOLTAGE = 15; //ANALOG
DATA_TYPE_LOCAL_OPERATION = 16; //DISCRETE
DATA_TYPE_OPERATION_COUNT = 17; //DISCRETE
DATA_TYPE_PACKET_LATENCY = 18; //ANALOG
DATA_TYPE_PHASE_VOLTAGE = 19; //ANALOG
DATA_TYPE_PHASOR_CURRENT = 20; //PHASOR
DATA_TYPE_PHASOR_VOLTAGE = 21; //PHASOR
DATA_TYPE_PMU_SYNC = 22; //DISCRETE (True or False)
DATA_TYPE_PMU_TIME_QUALITY = 23; //DISCRETE
DATA_TYPE_PMU_TRIGGER_DETECTED = 24; //DISCRETE (True or False)
DATA_TYPE_POWER = 25; //ANALOG
DATA_TYPE_POWER_FACTOR = 26; //ANALOG
DATA_TYPE_PRESSURE = 27; //ANALOG
DATA_TYPE_RATE_OF_CHANGE_OF_FREQUENCY = 28; //ANALOG
DATA_TYPE_REACTIVE_POWER = 29; //ANALOG
DATA_TYPE_SWITCH_POSITION = 30; //DISCRETE (True or False)
DATA_TYPE_TAP_POSITION = 31; //DISCRETE
DATA_TYPE_TEMPERATURE = 32; //ANALOG
DATA_TYPE_THREE_PHASE_ACTIVE_POWER = 33; //ANALOG
DATA_TYPE_THREE_PHASE_CURRENT = 34; //ANALOG
DATA_TYPE_THREE_PHASE_POWER = 35; //ANALOG
DATA_TYPE_THREE_PHASE_POWER_FACTOR = 36; //ANALOG
DATA_TYPE_THREE_PHASE_REACTIVE_POWER = 37; //ANALOG
DATA_TYPE_TRIGGER_REASON = 38; //DISCRETE
DATA_TYPE_UNLOCKED_TIME = 39; //DISCRETE
DATA_TYPE_VOLTAGE_SEQUENCE_NEGATIVE = 40; //PHASOR
DATA_TYPE_VOLTAGE_SEQUENCE_POSITIVE = 41; //PHASOR
DATA_TYPE_VOLTAGE_SEQUENCE_ZERO = 42; //PHASOR
DATA_TYPE_DISCRETE = 43; //DISCRETE
DATA_TYPE_ANALOG = 44; //ANALOG
}

message Data {
DataType dataType = 1;
int64 measuredAt = 2;
Expand Down
16 changes: 9 additions & 7 deletions proto/task/v1/task.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ package task.v1;
option go_package = "./task";

enum TaskType {
COLLECTION = 0;
TOPOLOGY = 1;
STATE = 2;
FAULT = 3;
TASK_TYPE_UNSPECIFIED = 0;
TASK_TYPE_COLLECTION = 1;
TASK_TYPE_TOPOLOGY = 2;
TASK_TYPE_STATE = 3;
TASK_TYPE_FAULT = 4;
}

enum NotificationType {
DATA_COMPLETE = 0;
DATA_TIMEOUT_1 = 1;
DATA_TIMEOUT_2 = 2;
NOTIFICATION_TYPE_UNSPECIFIED = 0;
NOTIFICATION_TYPE_DATA_COMPLETE = 1;
NOTIFICATION_TYPE_DATA_TIMEOUT_1 = 2;
NOTIFICATION_TYPE_DATA_TIMEOUT_2 = 3;
}


Expand Down

0 comments on commit be08b46

Please sign in to comment.