pub struct ChalkGrpcClient { /* private fields */ }Expand description
A gRPC client for the Chalk feature store.
ChalkGrpcClient is an alternative to ChalkClient
that uses gRPC (HTTP/2 + Protocol Buffers) instead of REST/JSON for lower
latency and higher throughput.
Supports query_proto, query_bulk_proto,
and upload_features_proto. These are
low-level methods that accept raw protobuf types. Offline queries are
only available via the REST client.
§Example
use chalk_client::ChalkGrpcClient;
use chalk_client::gen::chalk::common::v1::{OnlineQueryRequest, OutputExpr};
use std::collections::HashMap;
let client = ChalkGrpcClient::new()
.client_id("your-client-id")
.client_secret("your-client-secret")
.environment("production")
.build()
.await?;
let request = OnlineQueryRequest {
inputs: HashMap::from([(
"user.id".to_string(),
prost_types::Value {
kind: Some(prost_types::value::Kind::NumberValue(42.0)),
},
)]),
outputs: vec![OutputExpr {
expr: Some(chalk_client::gen::chalk::common::v1::output_expr::Expr::FeatureFqn(
"user.name".to_string(),
)),
}],
..Default::default()
};
let response = client.query_proto(request).await?;Implementations§
Source§impl ChalkGrpcClient
impl ChalkGrpcClient
Sourcepub fn new() -> ChalkGrpcClientBuilder
pub fn new() -> ChalkGrpcClientBuilder
Creates a new ChalkGrpcClientBuilder with authentication settings configured.
Configuration is resolved from the first available source:
- Explicit values passed to the builder.
- Environment variables:
CHALK_CLIENT_ID,CHALK_CLIENT_SECRET,CHALK_API_SERVER,CHALK_ACTIVE_ENVIRONMENT. ~/.chalk.ymlfile, created by runningchalk login.
Source§impl ChalkGrpcClient
impl ChalkGrpcClient
Sourcepub async fn query_proto(
&self,
request: ProtoOnlineQueryRequest,
) -> Result<ProtoOnlineQueryResponse>
pub async fn query_proto( &self, request: ProtoOnlineQueryRequest, ) -> Result<ProtoOnlineQueryResponse>
Low-level: computes feature values for a single entity using the raw protobuf request/response types.
Prefer a higher-level wrapper (when available) over constructing proto messages by hand. See https://docs.chalk.ai/docs/query-basics.
Sourcepub async fn query_bulk_proto(
&self,
request: ProtoOnlineQueryBulkRequest,
) -> Result<ProtoOnlineQueryBulkResponse>
pub async fn query_bulk_proto( &self, request: ProtoOnlineQueryBulkRequest, ) -> Result<ProtoOnlineQueryBulkResponse>
Low-level: computes feature values for multiple entities at once using the raw protobuf request/response types.
Inputs and outputs use Arrow IPC (Feather) encoding inside the proto messages.
Sourcepub async fn upload_features_proto(
&self,
request: ProtoUploadFeaturesBulkRequest,
) -> Result<ProtoUploadFeaturesBulkResponse>
pub async fn upload_features_proto( &self, request: ProtoUploadFeaturesBulkRequest, ) -> Result<ProtoUploadFeaturesBulkResponse>
Low-level: uploads pre-computed feature values using the raw protobuf request/response types.
Sourcepub fn environment_id(&self) -> &str
pub fn environment_id(&self) -> &str
Returns the resolved environment ID.
Sourcepub fn config(&self) -> &ChalkClientConfig
pub fn config(&self) -> &ChalkClientConfig
Returns the current client configuration.
Auto Trait Implementations§
impl !Freeze for ChalkGrpcClient
impl !RefUnwindSafe for ChalkGrpcClient
impl Send for ChalkGrpcClient
impl Sync for ChalkGrpcClient
impl Unpin for ChalkGrpcClient
impl UnsafeUnpin for ChalkGrpcClient
impl !UnwindSafe for ChalkGrpcClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request