Golang struct with Protobuf Data coverting issues

We have golang struct like below, in the MetricsValues SLAMetrics is a protobuf object,

type ExecutionResult struct {
	// Unique identifier.
	Id *RunId
	// Represents an id in the Falcon for test run.
	ExecutionId string
	// SLAMetrics values from the run.
	MetricsValues map[*metric.SLAMetric]int32
}

by using the default converter from go sdk we are getting errors like this:
Error values[0]: unable to encode: json: unsupported type: map[*pbsla_metric.SLAMetric]int32

Since this should be a pretty common case for data converter, are we going to support this case in the sdk/converter?

1 Like

@alex since I saw you worked on gosdk converter.

The provided data converters don’t support mixed go/proto structures. Either make the whole ExecutionResult a protobuf or change SLAMetric to a Go struct.

Another option is to write your own DataConverter that supports such mixed structures.

Yes, Maxim is right. Default data converter just check every parameter or return value, and if it is proto – uses proto JSON. We don’t reflect input or result structs themselves. Yes, it is possible but we don’t want to go into this business. You can create your own DataConverter though and handle only your specific case there (based on name for example) or make it generic.

Another option would be to split this struct to 3 parameters and wrap map inside some proto message like MetricsValues (parameter must implement proto.Message.