Skip to content

Commit

Permalink
make end_time/start_time and continuation_token mutual exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
xiafu-msft committed Sep 4, 2020
1 parent 6992395 commit a428714
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def list_changes(self, **kwargs):
:keyword datetime start_time:
Filters the results to return only events which happened after this time.
If start_time and continuation_token are both set, start_time will be ignored.
:keyword datetime end_time:
Filters the results to return only events which happened before this time.
:keyword int results_per_page:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ def __init__(
start_time=None,
end_time=None,
continuation_token=None):
if (start_time or end_time) and continuation_token:
raise ValueError("start_time/end_time and continuation_token shouldn't be specified at the same time")
super(ChangeFeedPaged, self).__init__(
get_next=self._get_next_cf,
extract_data=self._extract_data_cb,
continuation_token=continuation_token or ""
)
# If start_time and continuation_token are both set, start_time will be ignored.
start_time = None if start_time and continuation_token else start_time

continuation_token = eval(continuation_token) if continuation_token else None

if continuation_token and container_client.primary_hostname != continuation_token['UrlHost']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ def list_events_in_live_mode(self):
# Instantiate a ChangeFeedClient
cf_client = ChangeFeedClient("https://{}.blob.core.windows.net".format(self.ACCOUNT_NAME),
credential=self.ACCOUNT_KEY)

start_time = datetime(2020, 9, 1, 1)
token = None

while True:
# start_time will be ignored if start_time and continuation_token are both non-empty
change_feed = cf_client.list_changes(start_time=start_time).by_page(continuation_token=token)
change_feed = cf_client.list_changes(results_per_page=500).by_page(continuation_token=token)

for page in change_feed:
for event in page:
Expand Down
Loading

0 comments on commit a428714

Please sign in to comment.