Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add page_size as a configurable parameter to mitigate 504 errors #14

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tap_mambu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
'user_agent'
]

DEFAULT_PAGE_SIZE = 500

def do_discover():

LOGGER.info('Starting discover')
Expand All @@ -35,7 +37,8 @@ def main():
with MambuClient(parsed_args.config['username'],
parsed_args.config['password'],
parsed_args.config['subdomain'],
parsed_args.config['user_agent']) as client:
int(parsed_args.config.get('page_size', DEFAULT_PAGE_SIZE)),
user_agent=parsed_args.config['user_agent']) as client:

state = {}
if parsed_args.state:
Expand Down
2 changes: 2 additions & 0 deletions tap_mambu/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ def __init__(self,
username,
password,
subdomain,
page_size,
user_agent=None):
self.__username = username
self.__password = password
self.__subdomain = subdomain
base_url = "https://{}.mambu.com/api".format(subdomain)
self.base_url = base_url
self.page_size = page_size
self.__user_agent = user_agent
self.__session = requests.Session()
self.__verified = False
Expand Down
2 changes: 1 addition & 1 deletion tap_mambu/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def sync_endpoint(client, #pylint: disable=too-many-branches
# Increase the "offset" by the "limit" for each batch.
# Continue until the "record_count" returned < "limit" is null/zero or
offset = 0 # Starting offset value for each batch API call
limit = 500 # Batch size; Number of records per API call
limit = client.page_size # Batch size; Number of records per API call
total_records = 0 # Initialize total
record_count = limit # Initialize, reset for each API call

Expand Down