پیکربندی محل داده‌ها با نقاط پایانی منطقه‌ای

این صفحه نحوه پیکربندی کتابخانه‌های کلاینت Cloud Firestore را برای استفاده از یک نقطه پایانی منطقه‌ای یا چند منطقه‌ای شرح می‌دهد.

وقتی از کتابخانه‌های کلاینت Cloud Firestore استفاده می‌کنید، می‌توانید از هر یک از نقاط پایانی زیر استفاده کنید:

  • Global endpoint : By default, the Cloud Firestore client libraries send API requests to a global service endpoint named firestore.googleapis.com . The global service endpoint routes the request to your database. During routing, a request might pass through a server in a location that's different from your database location.

  • Regional endpoint : A regional endpoint enforces restrictions ensuring that data is transmitted, stored and processed in a specified Google Cloud region. To ensure that the service endpoint processes your app's Cloud Firestore requests in the same region as your database, specify a regional endpoint in the client library.

  • Multi-regional endpoint : A multi-regional endpoint enforces restrictions ensuring that data is stored and processed in a specified multi-region. To ensure that the service endpoint processes your app's Cloud Firestore requests in the same multi-region as your database, specify a multi-regional endpoint in the client library.

یک نقطه پایانی منطقه‌ای یا چند منطقه‌ای تنظیم کنید

روش پیکربندی یک نقطه پایانی منطقه‌ای یا چند منطقه‌ای یکسان است: شما رشته نقطه پایانی را هنگام مقداردهی اولیه کتابخانه کلاینت ارائه می‌دهید. مثال‌های زیر نحوه تنظیم رشته نقطه پایانی را با استفاده از یک نقطه پایانی منطقه‌ای ( firestore.us-central1.rep.googleapis.com ) نشان می‌دهند. برای استفاده از یک نقطه پایانی چند منطقه‌ای، یک رشته نقطه پایانی چند منطقه‌ای مربوط به موقعیت پایگاه داده خود ارائه دهید (برای مثال، firestore.us.rep.googleapis.com برای nam5 ).

جاوا

برای اطلاعات بیشتر در مورد نصب و ایجاد یک کلاینت Cloud Firestore ، به کتابخانه‌های کلاینت Cloud Firestore مراجعه کنید.


import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.FirestoreOptions;


/**
 * Demonstrate how to set a regional endpoint.
 */
public class RegionalEndpointSnippets {

  /**
   * Create a client with a regional endpoint.
   **/
  public Firestore regionalEndpoint(String projectId, String endpoint) throws Exception {
    FirestoreOptions firestoreOptions =
        FirestoreOptions.newBuilder()
            .setProjectId(projectId)
            .setCredentials(GoogleCredentials.getApplicationDefault())
            // set endpoint like firestore.us-central1.rep.googleapis.com:443
            .setHost(endpoint)
            .build();
    Firestore dbWithEndpoint = firestoreOptions.getService();

    return dbWithEndpoint;
  }

}

پایتون

برای اطلاعات بیشتر در مورد نصب و ایجاد یک کلاینت Cloud Firestore ، به کتابخانه‌های کلاینت Cloud Firestore مراجعه کنید.

ENDPOINT = "firestore.africa-south1.rep.googleapis.com"
client_options = ClientOptions(api_endpoint=ENDPOINT)
db = firestore.Client(client_options=client_options)

cities_query = db.collection("cities").limit(2).get()
for r in cities_query:
    print(r)

معناشناسی نقاط پایانی منطقه‌ای و چند منطقه‌ای

نقاط پایانی منطقه‌ای (REP):

Cloud Firestore از نقاط پایانی منطقه‌ای برای مکان‌های منطقه‌ای ذکر شده در اینجا، مکان‌های Cloud Firestore پشتیبانی می‌کند.

برای تعریف نقاط پایانی منطقه‌ای از قالب زیر استفاده کنید:

جاوا

  firestore.REGION_NAME.rep.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

پایتون

  firestore.REGION_NAME.rep.googleapis.com

برو

  firestore.REGION_NAME.rep.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

به جای REGION_NAME ، نام میزبان منطقه‌ای خود را وارد کنید.

چند نمونه از نام‌های میزبان عبارتند از:

  • firestore.us-central1.rep.googleapis.com
  • firestore.europe-west1.rep.googleapis.com

نقاط پایانی چند منطقه‌ای (MREP)

برای نقاط پایانی چند منطقه‌ای، us برای مکان‌های nam5 و nam7 و eu برای مکان eur3 استفاده کنید (به مکان‌های چند منطقه‌ای مراجعه کنید).

جاوا

  firestore.us.rep.googleapis.com:443
  firestore.eu.rep.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

پایتون

  firestore.us.rep.googleapis.com
  firestore.eu.rep.googleapis.com

برو

  firestore.us.rep.googleapis.com:443
  firestore.eu.rep.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

محدودیت‌ها

نقاط پایانی مکانی (منسوخ شده)

نقاط پایانی مکانی اکنون منسوخ شده‌اند. به جای آن از نقاط پایانی منطقه‌ای یا چند منطقه‌ای استفاده کنید.

Cloud Firestore قبلاً از نقاط انتهایی مکانی با فرمت زیر پشتیبانی می‌کرد:

جاوا

  REGION_NAME-firestore.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

پایتون

  REGION_NAME-firestore.googleapis.com

برو

  REGION_NAME-firestore.googleapis.com:443

مطمئن شوید که شماره پورت به همراه نقطه پایانی تعریف شده باشد.

به جای REGION_NAME ، نام یک نام میزبان منطقه‌ای یا چند منطقه‌ای را قرار دهید.

چند نمونه از نام‌های میزبان عبارتند از:

  • eur3-firestore.googleapis.com
  • nam5-firestore.googleapis.com
  • europe-west6-firestore.googleapis.com
  • asia-northeast2-firestore.googleapis.com

برای مشاهده لیست کاملی از نام‌های میزبان چند منطقه‌ای و منطقه‌ای، به مکان‌های Cloud Firestore مراجعه کنید.

محدود کردن استفاده از نقاط پایانی API سراسری

To help enforce the use of regional and multi-regional endpoints, use the constraints/gcp.restrictEndpointUsage organization policy constraint to block requests to the global API endpoint. For more information, see Restricting endpoint usage .