Skip to main content

ChalkGrpcClient

Struct ChalkGrpcClient 

Source
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

Source

pub fn new() -> ChalkGrpcClientBuilder

Creates a new ChalkGrpcClientBuilder with authentication settings configured.

Configuration is resolved from the first available source:

  1. Explicit values passed to the builder.
  2. Environment variables: CHALK_CLIENT_ID, CHALK_CLIENT_SECRET, CHALK_API_SERVER, CHALK_ACTIVE_ENVIRONMENT.
  3. ~/.chalk.yml file, created by running chalk login.
Source§

impl ChalkGrpcClient

Source

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.

Source

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.

Source

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.

Source

pub fn environment_id(&self) -> &str

Returns the resolved environment ID.

Source

pub fn config(&self) -> &ChalkClientConfig

Returns the current client configuration.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more