Replies: 1 comment 1 reply
-
Glad to see the discussion get started and a good outline of the questions / challenges. Some questions on this block from the proposed Type State Pattern example (final code block):
I have some other thoughts but some of it is dependent on answers to the above questions. One question I did have... Is it possible to just not support V2 pact creation in pact-go@v2? The provider would still be able to verify existing v2 pacts but part of migrating to pact-go@v2 would be migrating any pact creation to v3, which doesn't impose any loss of functionality, only a slightly greater difference in the API. As a code change is required as part of the migration anyway, impact seems minimal to me, but there may be factors I am missing. |
Beta Was this translation helpful? Give feedback.
-
Background / Problem
See this Draft PR for background.
Seeing version numbers as part of function names in an exported API is a bit awkward, leading to this sort of thing:
Challenges
GivenWithParam
) and multiple states per interaction. V2 doesn't support Message Pact which is currently supported via a separate API.(see the full list here: https://github.com/pact-foundation/pact-specification/tree/version-3)
Example plugin API:
(via https://github.com/pact-foundation/pact-plugins/blob/7378ab4846a60af7513d69f6ea4c2fdd3c19363f/examples/csv/csv-consumer-rust/src/lib.rs#L87-L98)
Solution Proposal 1: Functional Options
See this article for more on the pattern.
It would result in an interface that looks more like this:
Whilst this is more visually appealing, it doesn't address the challenges brought with v4 and we'd need to work around things that aren't compatible in v2 (probably manageable).
Solution Proposal 2: Type state pattern
The upside of this approach, is that you still start with a single entrypoint and can control what behaviour is allowed via the return types, and ensure the system can't get into an invalid state. The main draw back is that there is more types that would need managing from a Maintainer perspective.
Beta Was this translation helpful? Give feedback.
All reactions