frostfs-api-go/util/proto/encoding/compat.go
Evgenii Stratonikov 03759317ef
Some checks failed
DCO action / DCO (pull_request) Failing after 2m20s
Tests and linters / Tests (1.19) (pull_request) Successful in 2m43s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m50s
Tests and linters / Tests with -race (pull_request) Successful in 3m7s
Tests and linters / Lint (pull_request) Failing after 3m53s
protogen: Initial implementation
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-08-06 16:56:37 +03:00

21 lines
593 B
Go

package encoding
import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/protoadapt"
)
// messageV2Of converts v to a proto.Message.
// This is needed for this library to continue working in presense of external gRPC packages,
// such as opentelemetry gRPC exporter.
// Copied from https://github.com/grpc/grpc-go/blob/e524655becd8d4c7ba9e8687faef456e495e341e/encoding/proto/proto.go#L59.
func messageV2Of(v any) proto.Message {
switch v := v.(type) {
case protoadapt.MessageV1:
return protoadapt.MessageV2Of(v)
case protoadapt.MessageV2:
return v
}
return nil
}