Skip to content

sift_client.transport.grpc_transport

Transport layer for gRPC communication.

This module provides a simple wrapper around sift_py/grpc/transport.py for making gRPC API calls. It just stores the channel and the stubs, without any additional functionality.

CLASS DESCRIPTION
GrpcClient

A simple wrapper around sift_py/grpc/transport.py for making gRPC API calls.

GrpcConfig

Configuration for gRPC API clients.

ATTRIBUTE DESCRIPTION
logger

logger module-attribute

logger = getLogger(__name__)

GrpcClient

GrpcClient(config: GrpcConfig)

A simple wrapper around sift_py/grpc/transport.py for making gRPC API calls.

This class just stores the channel and the stubs, without any additional functionality.

Initialize the gRPC client.

PARAMETER DESCRIPTION
config

The gRPC client configuration.

TYPE: GrpcConfig

METHOD DESCRIPTION
close

Close sync and async channels and stop the default loop.

close_sync

Close the sync channel and all async channels.

get_stub

Get an async stub bound to the current event loop.

ATTRIBUTE DESCRIPTION
default_loop

Return the default event loop used for synchronous API operations.

TYPE: AbstractEventLoop

default_loop property

default_loop: AbstractEventLoop

Return the default event loop used for synchronous API operations.

RETURNS DESCRIPTION
AbstractEventLoop

The default asyncio event loop.

close async

close()

Close sync and async channels and stop the default loop.

close_sync

close_sync()

Close the sync channel and all async channels.

get_stub

get_stub(stub_class: type[Any]) -> Any

Get an async stub bound to the current event loop. Creates a channel and stub for this loop if needed.

GrpcConfig

GrpcConfig(
    url: str,
    api_key: str,
    use_ssl: bool = True,
    cert_via_openssl: bool = False,
    metadata: dict[str, str] | None = None,
)

Configuration for gRPC API clients.

Initialize the gRPC configuration.

PARAMETER DESCRIPTION
url

The URI of the gRPC server.

TYPE: str

api_key

The API key for authentication.

TYPE: str

use_ssl

Whether to use SSL/TLS.

TYPE: bool DEFAULT: True

cert_via_openssl

Whether to use OpenSSL for SSL/TLS.

TYPE: bool DEFAULT: False

use_async

Whether to use async gRPC client.

metadata

Additional metadata to include in all requests.

TYPE: dict[str, str] | None DEFAULT: None

ATTRIBUTE DESCRIPTION
api_key

cert_via_openssl

metadata

uri

use_ssl

api_key instance-attribute

api_key = api_key

cert_via_openssl instance-attribute

cert_via_openssl = cert_via_openssl

metadata instance-attribute

metadata = metadata or {}

uri instance-attribute

uri = normalized_url

use_ssl instance-attribute

use_ssl = use_ssl