sift_py.grpc.transport
¶
This module is concerned with creating a gRPC transport channel specifically for
interacting with Sift's gRPC API. the use_sift_channel method creates said channel
and should generally be used within a with-block for correct resource management.
| CLASS | DESCRIPTION |
|---|---|
SiftChannelConfig |
Config class used to instantiate a |
| FUNCTION | DESCRIPTION |
|---|---|
get_ssl_credentials |
Returns SSL credentials for use with gRPC. |
use_sift_async_channel |
Like |
use_sift_channel |
Returns an intercepted channel that is meant to be used across all services that |
| ATTRIBUTE | DESCRIPTION |
|---|---|
SiftAsyncChannel |
TYPE:
|
SiftChannel |
TYPE:
|
SiftChannelConfig
¶
Bases: TypedDict
Config class used to instantiate a SiftChannel via use_sift_channel.
- uri: The URI of Sift's gRPC API. The scheme portion of the URI i.e. https:// should be ommitted.
- apikey: User-generated API key generated via the Sift application.
- enable_keepalive: Enabled by default, but can be disabled by passing in False. HTTP/2 keep-alive prevents connections from
being terminated during idle periods. A custom sift_py.grpc.keepalive.KeepaliveConfig may also be provided.
- use_ssl: INTERNAL USE. Meant to be used for local development.
- cert_via_openssl: Enable this if you want to use OpenSSL to load the certificates.
Run pip install sift-stack-py[openssl] to install the dependencies required to use this option.
This works around this issue with grpc loading SSL certificates: https://github.com/grpc/grpc/issues/29682.
Default is False.
| ATTRIBUTE | DESCRIPTION |
|---|---|
apikey |
TYPE:
|
cert_via_openssl |
TYPE:
|
enable_keepalive |
TYPE:
|
uri |
TYPE:
|
use_ssl |
TYPE:
|
get_ssl_credentials
¶
get_ssl_credentials(
cert_via_openssl: bool,
) -> ChannelCredentials
Returns SSL credentials for use with gRPC. Workaround for this issue: https://github.com/grpc/grpc/issues/29682
use_sift_async_channel
¶
use_sift_async_channel(
config: SiftChannelConfig,
metadata: Optional[Dict[str, Any]] = None,
) -> SiftAsyncChannel
Like use_sift_channel but returns a channel meant to be used within the context
of an async runtime when asynchonous I/O is required.
use_sift_channel
¶
use_sift_channel(
config: SiftChannelConfig,
metadata: Optional[Dict[str, Any]] = None,
) -> SiftChannel
Returns an intercepted channel that is meant to be used across all services that make RPCs to Sift's API. It is highly encouraged to use this within a with-block for correct resource clean-up.
Should an RPC fail for a reason that isn't explicitly controlled by Sift, SiftChannel
will automatically leverage gRPC's retry mechanism to try and recover until the max-attempts
are exceeded, after which the underlying exception will be raised.