All Products
Search
Document Center

Alibaba Cloud Service Mesh:Description of ASMGrpcJsonTranscoder

Last Updated:Mar 25, 2025

ASMGrpcJsonTranscoder is used for transcoding between HTTP/JSON and gRPC/Protobuf. This topic describes the fields of ASMGrpcJsonTranscoder.

Field description

Field

Type

Required

Description

workloadSelector

map<string, string>

Yes

One or more labels that specify a set of pods on which the configurations take effect. The scope of label search is restricted to the namespace in which the resource resides. For more information, see Workload Selector.

isGateway

bool

No

Specifies whether to apply the configurations to a gateway. The value true indicates that the configurations apply to the gateway. Default value: false.

portNumber

int

Yes

The corresponding service port. If the configurations apply to a gateway, this field specifies the service port (such as 8080) that performs transcoding on the gateway.

services

string[]

Yes

The services that the configurations declared in the Proto file in the {package name}.{service name} format. Example:

services:
 - 'helloworld.Greeter'

protoDescriptorBin

string

Yes

The Base64-encoded content of the Proto Descriptor file. Note that the value of this field must be Base64-encoded.

transcodeFirst

bool

No

Default value: false. The value true indicates that an HTTP requests is transcoded first before other processing. This may affect the request-based traffic control features. For example, if the request sent to custom external authorization services is transcoded first, the service receives a gRPC request. Otherwise, it will receive an HTTP request.

convertGrpcStatus

bool

No

The default value is false. Specifies whether to convert grpc-status to JSON. After you set this parameter to true, the google.rpc.Status message will be retrieved from grpc-status-details-bin header and used as the JSON body when a gRPC error returned from upstream services and no HTTP body responses are available. If such a header does not exist, a google.rpc.Status message will be generated based on the grpc-status and grpc-message.

For example, the upstream server responses with the following header:

grpc-status: 5
grpc-status-details-bin: CAUaMwoqdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucnBjLlJlcXVlc3RJbmZvEgUKA3ItMQ

The grpc-status-details-bin header contains a Base64-encoded protobuf message google.rpc.Status. It will be converted to:

HTTP/1.1 404 Not Found
content-type: application/json
{
"code": 5,
"details": [
        {
        "@type": "type.googleapis.com/google.rpc.RequestInfo",
        "requestId": "r-1"
        }
    ]
}

ignoredQueryParameters

[]string

No

The query parameters that are ignored when transcoding method is mapped. By default, if any unknown or invalid query parameters exist, the transcoder will not transcode the request. The ignored HTTP request query parameters declared in ignoredQueryParameters will be ignored when they appear in the request, and the request can be transcoded.

ignoreUnknownQueryParameters

bool

No

The query parameters to specify whether to ignore HTTP request that cannot be mapped to corresponding protobuf fields. Configure this parameter if unknown query parameters exist. Otherwise, configure ignoredQueryParameters.

Important

If both ignoredQueryParameters and ignoreUnknownQueryParameters are configured, the configuration declared in ignoredQueryParameters will be invalid. Proceed with caution.

References

Use ASMGrpcJsonTranscoder to allow HTTP/JSON requests to access gRPC services in an ASM instance