Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Support compressed write #792

Closed
wants to merge 4 commits into from

Conversation

noradtux
Copy link

@noradtux noradtux commented Mar 1, 2020

Modify InfluxDBClient.write() to allow compression of data before posting. Works for me.

Contributor checklist
  • Builds are passing
  • New tests have been added (for feature additions)

@sebito91 sebito91 self-assigned this Apr 8, 2020
Copy link
Contributor

@sebito91 sebito91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @noradtux! Could you please look to address the feedback and add a test case to ensure this is working as expected?

@@ -98,6 +100,13 @@ def __init__(self,
self._database = database
self._timeout = timeout
self._retries = retries
if compression is True:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing as we don't know what type the compression parameter should be. Can you please update the function to include comments on what to expect from this paramater? Should self._compression be an int, bool, something else?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually it might be int or bool at that point. If it just True the code will choose a default int value. Seemed sensible to me back when I implemented it. Now I am not so sure anymore ... Suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if anything you should define two vars, one for the switch on/off of compression and another for the level.

else:
self._compression = compression

assert self._compression is False or \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we blow up here if we don't match one of the values? This should be set to a proper default and move along without any issue for the user.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok, will do. Usualy I prefer my code to blow up instead of hiding bugs ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you flip this to be two parameters as outline above then this should give you enough assurance that things are working as expected.

@noradtux
Copy link
Author

Could you please ... add a test case to ensure this is working as expected?
I guess I need to modify tests/client_test.py? I will try ...

@sebito91
Copy link
Contributor

If you cannot mock out a test for data, just do a simple test to instantiate the client with your options defined and add your assert to confirm they're configured as you'd expect.

I think if anything ensuring the gzip header is present in a mocked request should suffice.

@cgiraldo
Copy link

I think this is already implemented in #732

@sebito91
Copy link
Contributor

I think the core if it is indeed implemented in #732, but I saw this as giving users the ability to define the compression level itself.

@noradtux if you feel that this is already covered in #732 and you'd like to rebase + amend to fit that structure, then please continue. Otherwise I'm OK if we decide to close this one outright.

@noradtux
Copy link
Author

Sorry, didn't have much time to look into this properly. I guess my implementation requires at least python 3.2, so the implementation in #732 seems to be more portable. Hence that one has already been merged this one is redundant and can be closed.

@noradtux noradtux closed this May 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants