Skip to content

Commit

Permalink
Rename the JSON Transformer field from valueFields to valuesFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
majabirmancevic committed Sep 30, 2024
1 parent cea8a4f commit 399692d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion pkg/messaging/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func CreateMessage(conn *protomfx.ConnByKeyRes, protocol, subject string, payloa

if conn.Profile.Transformer != nil {
msg.Profile.Transformer = &protomfx.Transformer{
ValueFields: conn.Profile.Transformer.ValueFields,
ValuesFilter: conn.Profile.Transformer.ValuesFilter,
TimeField: conn.Profile.Transformer.TimeField,
TimeFormat: conn.Profile.Transformer.TimeFormat,
TimeLocation: conn.Profile.Transformer.TimeLocation,
Expand Down
156 changes: 78 additions & 78 deletions pkg/proto/mfx.pb.go

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

2 changes: 1 addition & 1 deletion pkg/proto/mfx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ message Profile {
}

message Transformer {
repeated string valueFields = 1;
repeated string valuesFilter = 1;
string timeField = 2;
string timeFormat = 3;
string timeLocation = 4;
Expand Down
4 changes: 2 additions & 2 deletions pkg/transformers/json/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (ts *transformerService) Transform(msg protomfx.Message) (interface{}, erro

switch p := payload.(type) {
case map[string]interface{}:
formattedPayload := transformPayload(p, msg.Profile.Transformer.ValueFields)
formattedPayload := transformPayload(p, msg.Profile.Transformer.ValuesFilter)
ret.Payload = formattedPayload

// Apply timestamp transformation rules depending on key/unit pairs
Expand All @@ -89,7 +89,7 @@ func (ts *transformerService) Transform(msg protomfx.Message) (interface{}, erro
}
newMsg := ret

formattedPayload := transformPayload(v, msg.Profile.Transformer.ValueFields)
formattedPayload := transformPayload(v, msg.Profile.Transformer.ValuesFilter)
newMsg.Payload = formattedPayload

// Apply timestamp transformation rules depending on key/unit pairs
Expand Down
6 changes: 3 additions & 3 deletions pkg/transformers/json/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const (
)

var (
valueFields = []string{"key1", "key2", "key3"}
valuesFilter = []string{"key1", "key2", "key3"}
)

var profile = &protomfx.Profile{Transformer: &protomfx.Transformer{ValueFields: valueFields, TimeField: "nanos_key", TimeFormat: timeFieldFormat, TimeLocation: timeFieldLocation}}
var profile = &protomfx.Profile{Transformer: &protomfx.Transformer{ValuesFilter: valuesFilter, TimeField: "nanos_key", TimeFormat: timeFieldFormat, TimeLocation: timeFieldLocation}}

func TestTransformJSON(t *testing.T) {
now := time.Now().Unix()
Expand All @@ -59,7 +59,7 @@ func TestTransformJSON(t *testing.T) {

microsMsg := msg
microsMsg.Payload = []byte(microsPayload)
microsMsg.Profile = &protomfx.Profile{Transformer: &protomfx.Transformer{ValueFields: valueFields, TimeField: "custom_ts_micro_key", TimeFormat: "unix_us", TimeLocation: timeFieldLocation}}
microsMsg.Profile = &protomfx.Profile{Transformer: &protomfx.Transformer{ValuesFilter: valuesFilter, TimeField: "custom_ts_micro_key", TimeFormat: "unix_us", TimeLocation: timeFieldLocation}}

invalidTimeField := msg
invalidTimeField.Payload = []byte(invalidTsPayload)
Expand Down
4 changes: 2 additions & 2 deletions things/api/grpc/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getConnByKeyEndpoint(svc things.Service) endpoint.Endpoint {
}

transformer := &protomfx.Transformer{
ValueFields: p.Transformer.ValueFields,
ValuesFilter: p.Transformer.ValuesFilter,
TimeField: p.Transformer.TimeField,
TimeFormat: p.Transformer.TimeFormat,
TimeLocation: p.Transformer.TimeLocation,
Expand Down Expand Up @@ -127,7 +127,7 @@ func getProfileByThingIDEndpoint(svc things.Service) endpoint.Endpoint {
}

transformer := &protomfx.Transformer{
ValueFields: p.Transformer.ValueFields,
ValuesFilter: p.Transformer.ValuesFilter,
TimeField: p.Transformer.TimeField,
TimeFormat: p.Transformer.TimeFormat,
TimeLocation: p.Transformer.TimeLocation,
Expand Down
2 changes: 1 addition & 1 deletion things/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Profile struct {
}

type Transformer struct {
ValueFields []string `json:"value_fields"`
ValuesFilter []string `json:"values_filter"`
TimeField string `json:"time_field"`
TimeFormat string `json:"time_format"`
TimeLocation string `json:"time_location"`
Expand Down

0 comments on commit 399692d

Please sign in to comment.