Skip to content

Conversation

@Jack-Keene
Copy link
Contributor

This PR adds a compression option to the Emitter.

Pass in a compression function to the compression parameter when initialising the emitter, eg:


def gzip_compression(data): 
    return gzip.compress(bytes(data, "UTF-8"))   

e = Emitter("localhost", compression=gzip_compression)

@snowplowcla snowplowcla added the cla:yes [Auto generated] Snowplow Contributor License Agreement has been signed. label Nov 22, 2023
@coveralls
Copy link

Coverage Status

coverage: 95.85% (-0.1%) from 95.946%
when pulling 4220b0a on test-compression-strategies
into b29a57d on master.

Comment on lines +245 to +252
@staticmethod
def print_request(req):
print('{}\n{}\r\n{}\r\n\r\n{}'.format(
'-----------START-----------',
req.method + ' ' + req.url,
'\r\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()), ""
))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just to demonstrate the size of the request

Comment on lines +261 to +266
req = requests.Request('POST', url=self.endpoint,
data=data,
headers={"Content-Type": "application/json; charset=utf-8"},
)
prepared = req.prepare()
self.print_request(prepared)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also to demonstrate the size of the request and wont be needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes [Auto generated] Snowplow Contributor License Agreement has been signed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants