8000 Ensure topic by pdeziel · Pull Request #30 · rotationalio/pyensign · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure topic #30

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

Merged
merged 3 commits into from
Jun 8, 2023
Merged

Ensure topic #30

merged 3 commits into from
Jun 8, 2023

Conversation

pdeziel
Copy link
Collaborator
@pdeziel pdeziel commented Jun 7, 2023

This PR adds an API for the user to ensure a topic exists. Ensure means to check if the topic exists, otherwise create it.

I have made the following changes:

  1. Added missing pytest-asyncio package to tests/requirements.txt
  2. Added ensure_topic_exists to the Ensign client
  3. Changed create_topic to return the topic ID instead of the protobuf topic

TODOs and questions

CHECKLIST

  • Is the commit message formatted correctly?
  • Do all of your functions and methods have docstrings?
  • Have you added/updated unit tests where appropriate?
  • Have you run the unit tests using pytest?
  • Is your code style correct (are you using PEP8, pyflakes)?

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #17635: Ensure topic API.

@pdeziel pdeziel requested a review from rebeccabilbro June 7, 2023 13:38
except EnsignTopicNotFoundError:
topic = await self.create_topic(topic_name)
topic_id = ULID.from_bytes(topic.id)
topic_id = await self.ensure_topic_exists(topic_name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I forgot that on publish pyensign was already creating the topic if it doesn't exist, so the user doesn't actually need to use ensure_topic_exists if they don't want to, but it did happen to clean up the code here a bit.

Copy link
Member

Choose a reason for hiding this comment

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

the oneliner here is 🔥 ;)

Copy link
Member
@rebeccabilbro rebeccabilbro left a comment

Choose a reason for hiding this comment

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

Looks good @pdeziel !

except EnsignTopicNotFoundError:
topic = await self.create_topic(topic_name)
topic_id = ULID.from_bytes(topic.id)
topic_id = await self.ensure_topic_exists(topic_name)
Copy link
Member

Choose a reason for hiding this comment

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

the oneliner here is 🔥 ;)

@pdeziel pdeziel merged commit a9571b3 into develop Jun 8, 2023
@pdeziel pdeziel deleted the sc-17635 branch June 8, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0