为 Discovery Engine API 实现客户端。
示例
# tokio_test::block_on(async {
# use google_cloud_discoveryengine_v1::client::RecommendationService;
let client = RecommendationService::builder().build().await?;
// use `client` to make requests to the Discovery Engine API.
# gax::client_builder::Result::<()>::Ok(()) });
服务说明
用于提供建议的服务。
配置
如需配置 RecommendationService,请使用 [builder()][RecommendationService::builder] 返回的类型中的 with_* 方法。默认配置应该适用于大多数应用。常见的配置更改包括
- with_endpoint():默认情况下,此客户端使用全球默认端点 (
https://discoveryengine.googleapis.com)。使用区域端点或在受限网络(例如,配置为覆盖此默认值的网络)中运行的应用。 - with_credentials():默认情况下,此客户端使用应用默认凭证。使用自定义身份验证的应用可能需要替换此默认值。
池化和克隆
RecommendationService 在内部保留一个连接池,建议创建一个连接池并重复使用。您无需将 RecommendationService 封装在 Rc 或 Arc 中即可重复使用它,因为它已在内部使用 Arc。
实现
构建器
fn builder() -> super::builder::recommendation_service::ClientBuilder
返回 [RecommendationService] 的构建器。
# tokio_test::block_on(async {
# use google_cloud_discoveryengine_v1::client::RecommendationService;
let client = RecommendationService::builder().build().await?;
# gax::client_builder::Result::<()>::Ok(()) });
from_stub
fn from_stub<T>(stub: T) -> Self
where
T: super::stub::RecommendationService + 'static,
通过提供的桩创建新客户端。
调用此函数的最常见情况是在模拟客户端行为的测试中。
recommend
fn recommend(self: &Self) -> super::builder::recommendation_service::Recommend
进行推荐,这需要一个上下文用户事件。
list_operations
fn list_operations(self: &Self) -> super::builder::recommendation_service::ListOperations
在此服务中提供操作服务功能。
get_operation
fn get_operation(self: &Self) -> super::builder::recommendation_service::GetOperation
在此服务中提供操作服务功能。
cancel_operation
fn cancel_operation(self: &Self) -> super::builder::recommendation_service::CancelOperation
在此服务中提供操作服务功能。