-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: adding pubsub * chore: support multiple subscription channels * chore: adding subscription items initial draft * chore: improved logging and error handling * chore: add topic validation * chore: adding synchronous functionality * fix: fix interceptor processing * chore: linting cleanup * chore: cleanup * chore: split topic subscribe response into synch and async classes * chore: typing, linting, and formatting work * chore: docstrings and other cleanup * chore: support more graceful cancellation of async streams * chore: add tests and fix usage of behaves_like decorator throughout * chore: fix up cancelled error a bit * chore: add docstrings * fix: formatting fixes * fix: correct an accidentally changed type * fix: more linting/formatting * chore: refactoring test shared behaviors * fix: fixing examples * fix: correct docstring * chore: remove redundant test cases * fix: add missing docstring for subscription item method * chore: change topic subscription responses into iterators * chore: update tests to use iterators * fix: test fixes
- Loading branch information
1 parent
e2593eb
commit ac7b626
Showing
42 changed files
with
1,777 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
|
||
class TopicConfigurationBase(ABC): | ||
@abstractmethod | ||
def get_max_subscriptions(self) -> int: | ||
pass | ||
|
||
@abstractmethod | ||
def with_max_subscriptions(self, max_subscriptions: int) -> TopicConfiguration: | ||
pass | ||
|
||
|
||
class TopicConfiguration(TopicConfigurationBase): | ||
"""Configuration options for Momento topic client.""" | ||
|
||
def __init__(self, max_subscriptions: int = 0): | ||
"""Instantiate a configuration. | ||
Args: | ||
max_subscriptions (int): The maximum number of subscriptions the client is expected | ||
to handle. Because each gRPC channel can handle 100 connections, we must explicitly | ||
open multiple channels to accommodate the load. NOTE: if the number of connection | ||
attempts exceeds the number the channels can support, program execution will block | ||
and hang. | ||
""" | ||
self._max_subscriptions = max_subscriptions | ||
|
||
def get_max_subscriptions(self) -> int: | ||
return self._max_subscriptions | ||
|
||
def with_max_subscriptions(self, max_subscriptions: int) -> TopicConfiguration: | ||
return TopicConfiguration(max_subscriptions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from .topic_configuration import TopicConfiguration | ||
|
||
|
||
class TopicConfigurations: | ||
class Default(TopicConfiguration): | ||
"""Provides the recommended default configuration for topic clients.""" | ||
|
||
@staticmethod | ||
def latest() -> TopicConfigurations.Default: | ||
"""Provides the latest recommended configuration for topics. | ||
This configuration will be updated every time there is a new version of the laptop configuration. | ||
""" | ||
return TopicConfigurations.Default.v1() | ||
|
||
@staticmethod | ||
def v1() -> TopicConfigurations.Default: | ||
"""Provides the v1 recommended configuration for topics. | ||
This configuration is guaranteed not to change in future releases of the Momento Python SDK. | ||
""" | ||
return TopicConfigurations.Default(max_subscriptions=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.