Cloud Endpoints는 사용자가 gRPC API 구성 YAML 파일에 구성한 이름을 서비스 이름으로 사용합니다.
API 서비스 이름은 Google Cloud에서 고유해야 합니다. Endpoints는 DNS 호환 이름을 사용하여 서비스를 식별하므로 API의 도메인 이름 또는 하위 도메인 이름을 서비스 이름으로 사용하는 것이 좋습니다. 이 방법을 따르면 Endpoints 서비스 페이지에 표시되는 서비스 이름이 API에 대한 요청에 사용된 이름과 일치하게 됩니다. 또한 서비스 이름과 도메인 이름이 같은 경우 API 사용자를 위한 Cloud Endpoints 포털을 만들 수 있습니다. Endpoints의 서비스 이름 요구사항은 다음과 같습니다.
도메인 이름 최대 길이는 253자(영문)입니다.
도메인 이름은 소문자로 시작해야 합니다.
점으로 구분된 도메인 이름의 각 섹션은 다음과 같은 요구사항을 충족해야 합니다.
소문자로 시작해야 합니다.
대시로 끝나서는 안 됩니다.
나머지 문자는 소문자, 숫자 또는 대시일 수 있습니다.
최대 길이는 63자입니다.
사용자 고유의 커스텀 도메인(예: example.com)을 등록하거나 Google에서 관리하는 도메인을 사용할 수 있습니다.
Google에서 관리하는 도메인 사용
Google은 cloud.goog 도메인을 소유하고 관리합니다. Google에서 관리하는 도메인을 사용하려면 Google Cloud 프로젝트 ID를 서비스 이름의 일부로 사용해야 합니다. Google Cloud 프로젝트에는 전역에서 고유한 프로젝트 ID가 있으므로 이 요구사항은 고유한 서비스 이름을 갖도록 보장합니다.
cloud.goog 도메인을 사용하려면 서비스 이름이 다음 형식이어야 하며 여기에서 YOUR_API_NAME은 API의 이름이고 YOUR_PROJECT_ID는 Google Cloud 프로젝트 ID입니다.
앞의 명령어에서 --proto_path는 현재 작업 디렉터리로 설정됩니다. gRPC 빌드 환경에서 .proto 입력 파일에 다른 디렉터리를 사용할 경우 컴파일러가 .proto 파일이 저장된 디렉터리를 검색하도록 --proto_path를 변경합니다.
설명자 파일을 생성하는 protoc 명령어가 실패할 경우 다음을 확인하세요.
protoc 버전이 최신 버전인지 여부
가져온 .proto 파일의 루트 디렉터리로 --proto_path 또는 축약형인 -I를 지정했는지 여부. 자세한 내용은 프로토콜 버퍼 문서를 참조하세요.
--include_imports를 지정했는지 여부
클라이언트에서 JSON이 적용된 HTTP를 사용하여 gRPC 서비스에 액세스하기를 원한다면 JSON이 적용된 HTTP에서 gRPC로 데이터가 전송되는 방법을 지정해야 합니다. .proto 파일에 정의된 API를 주석 처리하는 것이 좋습니다. 자세한 내용은 HTTP/JSON을 gRPC로 트랜스코딩을 참조하세요.
gRPC 서비스 구성 파일 구성
gRPC 서비스 구성 YAML 파일을 만들어야 합니다. 이 파일에서 서비스 이름과 사용 제한(예: API 키 요구 등)을 지정합니다.
Bookstore 샘플의 api_config.yaml 파일을 모델로 사용할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["\u003cp\u003eThis guide provides instructions for configuring a gRPC service that is managed by Cloud Endpoints, including required setup steps and prerequisites.\u003c/p\u003e\n"],["\u003cp\u003eThe service name configured in the gRPC API YAML file must be unique on Google Cloud and is recommended to match the API's domain or subdomain name for easier management and potential Cloud Endpoints Portal creation.\u003c/p\u003e\n"],["\u003cp\u003eYou can use either a Google-managed domain (\u003ccode\u003ecloud.goog\u003c/code\u003e) or a custom domain for your gRPC service, each with specific requirements for naming and verification.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring the protocol buffer involves creating a \u003ccode\u003e.proto\u003c/code\u003e file, compiling it with the \u003ccode\u003eprotoc\u003c/code\u003e compiler, and optionally setting up HTTP/JSON transcoding for client access.\u003c/p\u003e\n"],["\u003cp\u003eA gRPC service configuration YAML file is required to define the service name, display title, API name, and usage restrictions, such as API key requirements, within the Endpoints environment.\u003c/p\u003e\n"]]],[],null,["# Configuring Cloud Endpoints\n\n[OpenAPI](/endpoints/docs/openapi/configure-endpoints \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nThis page describes the configuration files needed to create a gRPC service\nthat is managed by Endpoints.\n\nPrerequisites\n-------------\n\nAs a starting point, this page assumes that you have:\n\n- A [Google Cloud project](/resource-manager/docs/creating-managing-projects).\n- Basic knowledge of [configuring a gRPC API service](/endpoints/docs/grpc/grpc-service-config).\n- Installed gRPC and the gRPC tools. Read [Get started with gRPC](https://grpc.io/docs/quickstart/) for details.\n\nChoosing the service name\n-------------------------\n\nCloud Endpoints uses the name you configure in your gRPC API configuration YAML file as the name of your service.\n\nThe name of your API service must be unique on Google Cloud. Because\nEndpoints uses DNS-compatible names to identify services, we\nrecommend that you use your API's domain name or subdomain name as the service\nname. With this approach, the service name that appears on the **Endpoints\nServices** page matches the name used in requests to your API.\nEndpoints has the following requirements for the service name:\n\nYou can either register your own custom domain (such as `example.com`), or\nyou can use a domain managed by Google.\n\n### Use a domain managed by Google\n\nGoogle owns and manages the `cloud.goog` domain. If you want to use a domain managed by Google, you must use your Google Cloud project ID as part of the service name. Because Google Cloud projects have a globally unique project ID, this requirement ensures that you have a unique service name. If you want to use the `cloud.goog` domain, the service name must be in the format, where \u003cvar translate=\"no\"\u003eYOUR_API_NAME\u003c/var\u003e is the name of your API and \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e is your Google Cloud project ID:\n\n\u003cbr /\u003e\n\n```\nYOUR_API_NAME.endpoints.YOUR_PROJECT_ID.cloud.goog`\n```\n\nTo use this domain as the API's domain name, read\n[Configuring DNS on the `cloud.goog` domain](/endpoints/docs/grpc/cloud-goog-dns-configure).\n\n\n### Use a custom domain\n\nIf you don't want to use a domain managed by Google, you can use a custom domain\n(for example, `myapi.mycompany.com`) that you are authorized to use.\nBefore you deploy the API configuration, follow the steps in\n[Verify ownership of the domain](/endpoints/docs/grpc/verify-domain-name).\n\nConfiguring the protocol buffer\n-------------------------------\n\n1. Create a `.proto` file for your service. Read the\n [Developer guide](https://developers.google.com/protocol-buffers/docs/overview) \n\n for details.\n\n2. Compile your protocol buffers by using the\n [`protoc` compiler](https://developers.google.com/protocol-buffers/docs/pythontutorial#compiling-your-protocol-buffers)\n for your language. For example:\n\n protoc\n --proto_path=. \\\n --include_imports \\\n --include_source_info \\\n --descriptor_set_out=api_descriptor.pb \\\n bookstore.proto\n\n In the preceding command, `--proto_path` is set to the current working\n directory. In your gRPC build environment, if you use a different directory\n for `.proto` input files, change `--proto_path` so the compiler searches the\n directory where you saved your `.proto` file.\n\n If the `protoc` command to generate your descriptor file fails, make sure that:\n - Your `protoc` version is up-to-date.\n - You specified the `--proto_path` or its short form `-I` for the root directories for imported `.proto` files. You can find out more in the [protocol buffers documentation](https://developers.google.com/protocol-buffers/docs/proto3#generating).\n - You specified `--include_imports`.\n\n If you want your clients to access your gRPC service by using\n HTTP with JSON, you need to specify how data is translated from\n HTTP with JSON to gRPC. We recommend that you annotate the APIs defined in\n your `.proto` file. Read\n [Transcoding HTTP/JSON to gRPC](/endpoints/docs/grpc/transcoding)\n for more information.\n\nConfiguring the gRPC service configuration file\n-----------------------------------------------\n\nYou need to create a gRPC service configuration YAML file. You specify the name\nof the service and usage restrictions, such as requiring an API key in this file.\nYou can use the `api_config.yaml` file from the Bookstore sample as a model.\n\n1. Save a copy of\n [`api_config.yaml`](https://raw.githubusercontent.com/GoogleCloudPlatform/python-docs-samples/master/endpoints/bookstore-grpc/api_config.yaml).\n\n2. Enter the name of your service in the `name` field. For example:\n\n name: bookstore.endpoints.example-project-12345.cloud.goog\n\n3. Enter the title that is displayed on the **Endpoints** \\\u003e **Services** page in\n the Google Cloud console. For example:\n\n title: Bookstore gRPC API\n\n4. Enter the API name in the `apis:name` field. The text that you enter must\n exactly match the fully-qualified API name from your `.proto` file. For\n example:\n\n ```\n apis:\n - name: endpoints.examples.bookstore.Bookstore\n ```\n5. Configure the rest of the file. For example:\n\n #\n # API usage restrictions.\n #\n usage:\n rules:\n # ListShelves methods can be called without an API Key.\n - selector: endpoints.examples.bookstore.Bookstore.ListShelves\n allow_unregistered_calls: true\n\n Read [Rules and selectors](/endpoints/docs/grpc/grpc-service-config#rules_and_selectors)\n for more information.\n\nWhat's next\n-----------\n\n- [Deploying the Endpoints configuration](/endpoints/docs/grpc/deploy-endpoints-config)\n- [Deploying the API backend](/endpoints/docs/grpc/deploy-api-backend)\n- [Configuring authentication](/endpoints/docs/grpc/authentication-method)\n\nAdditional gRPC samples\n-----------------------\n\n- [Java version of the Bookstore sample](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/endpoints/bookstore-grpc).\n- The `getting-started-grpc` sample is available on GitHub in the following\n languages:\n\n - [Java](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/endpoints/getting-started-grpc)\n - [Python](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/endpoints/getting-started-grpc)\n - [Ruby](https://github.com/GoogleCloudPlatform/ruby-docs-samples/tree/master/endpoints/getting-started-grpc)\n - [Go](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/endpoints/getting-started-grpc)\n - [Node.js](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/endpoints/getting-started-grpc)"]]