func NewGRPCTranscoderFilterGenFromOPConfig()

in src/go/configgenerator/filtergen/grpc_transcoder.go [84:141]


func NewGRPCTranscoderFilterGenFromOPConfig(serviceConfig *confpb.Service, opts options.ConfigGeneratorOptions, maybeSkipFilter bool) (*GRPCTranscoderGenerator, error) {
	if maybeSkipFilter && opts.LocalHTTPBackendAddress != "" {
		glog.Warningf("Local http backend address is set to %q; skip transcoder filter completely.", opts.LocalHTTPBackendAddress)
		return nil, nil
	}

	isGRPCSupportRequired, err := IsGRPCSupportRequiredForOPConfig(serviceConfig, opts)
	if err != nil {
		return nil, err
	}
	if maybeSkipFilter && !isGRPCSupportRequired {
		glog.Infof("gRPC support is NOT required, skip transcoder filter completely.")
		return nil, nil
	}

	descBin, err := GetDescriptorBinFromOPConfig(serviceConfig)

	if err != nil {
		glog.Error("Unable to setup gRPC-JSON transcoding because no proto descriptor was found in the service config.")
		return nil, nil
	}

	descBin, err = UpdateProtoDescriptorFromOPConfig(serviceConfig, opts, descBin)
	if err != nil {
		return nil, err
	}

	ignoredQueryParams, err := GetIgnoredQueryParamsFromOPConfig(serviceConfig, opts)
	if err != nil {
		return nil, err
	}

	disabledSelectors, err := GetHTTPBackendSelectorsFromOPConfig(serviceConfig, opts)
	if err != nil {
		return nil, err
	}

	serviceNames := GetAPINamesListFromOPConfig(serviceConfig, opts)

	return &GRPCTranscoderGenerator{
		ProtoDescriptorBin:                 descBin,
		ServiceNames:                       serviceNames,
		IgnoredQueryParams:                 ignoredQueryParams,
		DisabledSelectors:                  disabledSelectors,
		IgnoreUnknownQueryParameters:       opts.TranscodingIgnoreUnknownQueryParameters,
		QueryParametersDisableUnescapePlus: opts.TranscodingQueryParametersDisableUnescapePlus,
		MatchUnregisteredCustomVerb:        opts.TranscodingMatchUnregisteredCustomVerb,
		CaseInsensitiveEnumParsing:         opts.TranscodingCaseInsensitiveEnumParsing,
		StrictRequestValidation:            opts.TranscodingStrictRequestValidation,
		RejectCollision:                    opts.TranscodingRejectCollision,
		PrintOptions: &transcoderpb.GrpcJsonTranscoder_PrintOptions{
			AlwaysPrintPrimitiveFields: opts.TranscodingAlwaysPrintPrimitiveFields,
			AlwaysPrintEnumsAsInts:     opts.TranscodingAlwaysPrintEnumsAsInts,
			PreserveProtoFieldNames:    opts.TranscodingPreserveProtoFieldNames,
			StreamNewlineDelimited:     opts.TranscodingStreamNewLineDelimited,
		},
	}, nil
}