-
Notifications
You must be signed in to change notification settings - Fork 6
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
API overhaul in moving to adc-streaming 1.x #82
Conversation
…r-based opts to subscribe
…sier testing, improve testing
…e with publish/subscribe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of review is done. I haven't reviewed tests and haven't reviewed all the doc changes yet.
This looks really good - a bunch of major improvements here to the clarity and consistency of the code. Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few notes on testing added. I think that we should get integration tests in here eventually, although now is probably not the time.
Thanks @spenczar for the thorough review! I'll start incorporating some of those changes you requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few suggestions in the code so far -- I'll add more as I dig deeper and do some testing.
hop/io.py
Outdated
if format in cls.__members__: | ||
return cls[format.upper()].value(**content) | ||
else: | ||
raise ValueError(f"Message format {format} not recognized") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spenczar A fallback to BLOB
happens when publishing an unspecified message -- it may be beneficial to have another fallback here, though I'm not sure if we need that redundancy in the internal Deserializer.
Codecov Report
@@ Coverage Diff @@
## master #82 +/- ##
==========================================
+ Coverage 86.99% 91.69% +4.69%
==========================================
Files 8 9 +1
Lines 223 325 +102
==========================================
+ Hits 194 298 +104
+ Misses 29 27 -2
|
9c338cc
to
ca4ead0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure all my changes have been addressed, looks great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, I resolved the previous comments. I did some CLI testing and found a few points, added in-line.
I definitely agree that integration testing should be one of the next steps as it'll be easier to find bugs like this.
This looks ready to me. Excellent work putting everything together! Looking forward to doing a release of all these changes soon. |
Description
This PR implements a number of changes to adapt to adc-streaming 1.x, as well as additional backwards-incompatible API changes. Since this needed to be done anyways for the upstream package, I took the liberty of making simplifications throughout as needed. This also implements #74 as it was easier wrapping this all up as part of these changes.
Overview:
hop auth
command with various utilities to create auth configuration and locate the path where this configuration is stored, used inhop publish
andhop subscribe
to authenticate.hop publish
andhop subscribe
API substantially, removing the-F
and-X
commands to pass in arbitrary configuration variables. Instead. this is all handled by the auth configuration above and loaded in by default, unless--no-auth
is specified. There is also no--timeout
arg forhop subscribe
, instead it reads messages until EOS is received. In order to open a long-lived connection, you can pass in--persist
instead.subscribe.classify_message
to aDeserializer
class inhop.io
. This is so the wrapping + serialization (or unwrapping+deserialization) of messages happens within the client itself.if not args:
in the entry points since it's basically unused and adds needless complexity.Selected files and motivation for changes:
Makefile:
flake8
to 12 for raising warnings. This is becauseio.Stream.open()
was raising warnings, and it was a bit obnoxious.README.md:
hop/init.py:
ImportError
behavior if_version.py
is not found, which was probably more trouble than its worth and not easily testable.hop/setup.cfg:
hop/auth.py:
hop auth locate
shows where the default auth config location lives, and can be controlled by $XDG_CONFIG_HOME. It usesget_auth_path()
to find this location.hop auth setup
creates an auth config file in that location if it doesn't already exist, and warns the user and does nothing if it does exist. You can overwrite the existing file withhop auth setup --force
.load_auth()
loads auth config from that default location and creates anAuth
instead, to be passed into astream
instance.hop/cli.py:
add_url_opts
toadd_client_opts
since this also now includes the--no-auth
option to be passed in by both publish/subscribe commands.hop/io.py:
Producer
andConsumer
classes and redefine how messages are serialized and deserialized to do message packing and to return the right message classes seamlessly. A lot of the functionality ofsubscribe.classify_message
has been folded into theDeserializer
class, which is used in the consumer. Most of these extra functions/classes, including exposing metadata is private since I don't want to expose any of this to the user.ConsumerStartPosition
from adc-streaming to control the message offset while not having to call adc directly.hop/models.py:
load()
andload_file()
, which should hopefully be more straightforward to handle message loading in the same way across all of these.wrap_message()
toserialize()
since this may actually serialize in the future and provide some future-proofing.hop/publish.py:
--format
argument options with the members ofio.Deserializer
. This is so users are required to choose between these options.hop/subscribe.py:
--earliest
with a--start-at
, with the same enum control as with--format
above. To specify earliest, one can do--start-at EARLIEST
now.--timeout
. By default, this will listen until EOS. If a long-lived connection is desired, the--persist
command is exposed.Extra notes
Checklist
/tests
, ensuring sufficient code coverage.make test
runs without errors.make lint
doesn't give any warnings.make format
doesn't give any code formatting suggestions.make doc
runs without errors and generated docs render correctly.NOTE: If this PR relates to a release, open and reference an issue with the Release checklist template.