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

Feat/async message consumer #714

Merged
merged 23 commits into from
Jun 24, 2024
Merged

Feat/async message consumer #714

merged 23 commits into from
Jun 24, 2024

Conversation

JP-Ellis
Copy link
Contributor

📝 Summary

  • Upgrade FFI to 0.4.21
  • Implement V3 and V4 asynchronous message consumer

Massive thanks to @valkolovos for doing most of the heavy lifting in #699 🚀 🚀

The reason for this separate PR is to assist with the generation of the changelog from the conventional Git commit history. Specifically because (1) a squashed commit would be insufficient to encapsulate the extent of the changes, and (2) a rebase-and-merge would be too verbose for the changelog.1

🚨 Breaking Changes

  • The message() iterator of the Pact class has been removed.
  • A number of deprecated classes have been removed from the FFI module.

🔥 Motivation

🔨 Test Plan

  • Compatibility suite has been implemented.
  • Examples have been added.

🔗 Related issues/PRs

Footnotes

  1. Unfortunately, it was too difficult to cherry-pick the commits from @valkolovos. As a result, I am marked as the author and committer for these commits, though I have made sure to credit @valkolovos with the Co-authored-by trailer.

JP-Ellis and others added 23 commits June 24, 2024 13:43
Use the `__all__` to mark the `Pact` and `Verifier` imports as public
re-exports, thereby removing the need to silence F401.

Signed-off-by: JP-Ellis <josh@jpellis.me>
Main changes include:

- Addition of a `PactAsyncMessageIterator` (and related functions)
- Addition of `*_generate_contents` functions which are analogous to the
  `*_get_contents` functions, but replace any matchers/generators with
  the relevant substitution in order to generate a 'real' payload.
- Addition of `with_metadata` to add metadat to an interaction
- Addition of `with_generators` to add generators to an interaction
- Deprecation of the `MessagePactHandle` and `MessageHandle`

Signed-off-by: JP-Ellis <josh@jpellis.me>
Define some type aliases for some enums. As a result of this, functions
which take a subclass of an `Enum` can be, fairly straightforwardly,
adapted to allow strings of the enum values.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
The `Generator` (and other closely related types) are returned by the
`MessageContents` type. These will generally not be used, but may prove
to be useful in a few select circumstances.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Along with associated types

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
The `InteractionHandle` is the intended way to define interactions, with
`Message` and `MessageHandle` being replaced by the former.

Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
A couple of minor changes to the docs clarifying the role of
`Interaction Part`, especially in the context of asynchronous messages.

Signed-off-by: JP-Ellis <josh@jpellis.me>
The previous docstrings did not clearly explain the purpose for the
filesystem class. As the examples are intended to be quite pedagogical,
the new docstring makes it very clear what it is meant to do/why it
exists.

Signed-off-by: JP-Ellis <josh@jpellis.me>
Define a new `PactError` base class, and define new errors to
encapsulate verification errors.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Instead of returning the iterators themselves, use `yield from`
constructs. This helps for two reasons:

1. Avoids needlessly exposing additional classes which serve no other
   purpose than to iterate over data.
2. Manages the lifetime of the iterators more clearly, preventing
   possible issues due to the underlying data mutating during iteration.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
As messages abstract away the transport layer, it is necessary for
Python to directly handle the messages through some user-defined
handler. The `verify` method implements this on the consumer side by
verifying that each message can be consumed.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
This change also includes a minor fix to ensure that the server is
fully started before the test proceeds.

Co-authored-by: valkolovos <val.kolovos@guildeducation.com>
Co-authored-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis added type:feature New feature difficulty:hard A task requiring a lot of work and an in-depth understanding of the codebase area:tests Relating to the testing priority:2-high Must be addressed as soon as possible area:examples Relating to the examples area:v3 Relating to the pact.v3 module labels Jun 24, 2024
@JP-Ellis JP-Ellis self-assigned this Jun 24, 2024
@JP-Ellis JP-Ellis merged commit 73f6599 into master Jun 24, 2024
38 of 39 checks passed
@JP-Ellis JP-Ellis deleted the feat/async-message-consumer branch June 24, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:examples Relating to the examples area:tests Relating to the testing area:v3 Relating to the pact.v3 module difficulty:hard A task requiring a lot of work and an in-depth understanding of the codebase priority:2-high Must be addressed as soon as possible type:feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support and example for a message consumer test using Rust engine
1 participant