Adam Cox
03/21/2023, 12:05 PMAdam Cox
03/21/2023, 1:56 PMlet mut pact_builder = PactBuilder::new_v4("message-consumer", "message-provider"); // Define the message consumer and provider by name
let mock_server = pact_builder
.using_plugin("websockets", None)
.await
// Adds an interaction given the message description and type.
.synchronous_message_interaction("Mallory Message", |mut i| async move {
/// ...
})
.await
.start_mock_server_async(Some("websockets/transport/websockets"))
.await;
pact_builder
.synchronous_messages()
.collect::<Vec<SynchronousMessage>>().len() // 0Adam Cox
03/21/2023, 1:57 PMlet mut pact_builder = PactBuilder::new_v4("message-consumer", "message-provider"); // Define the message consumer and provider by name
let mut pact_builder_async = pact_builder.using_plugin("websockets", None).await;
let mock_server = pact_builder_async
.synchronous_message_interaction("Mallory Message", |mut i| async move {
// ...
})
.await
.start_mock_server_async(Some("websockets/transport/websockets"))
.await;
pact_builder_async
.synchronous_messages()
.collect::<Vec<SynchronousMessage>>()
.len() // 0Adam Cox
03/21/2023, 1:59 PMusing_plugin and get the PactBuilderAsync. The async one then becomes the one we need to work with and keeping the reference to it in stop is what stops the server from shutting downAdam Cox
03/21/2023, 2:05 PMYousaf Nabi (pactflow.io)
uglyog
Adam Cox
03/22/2023, 9:05 AMAdam Cox
03/22/2023, 9:07 AMOh, that could be a trap for lots of people. I’ll need to think of a way to get the first builder to hold the reference to the second one.For the signature of use_plugin could you just do
self instead of &self and move the ownership?Adam Cox
03/22/2023, 9:10 AMconfigure_interaction, generate_content and compare_contents only relevant if we are adding new Generator and Matcher catalogue entries? We aren’t adding those so do we need to worry much about their implementation.
btw, I think the plugin architecture is a brilliant idea and bravo for moving everything to Rust. The tooling is so much more portable and extensible this way and it allows us to get things done as we need to. Great job!uglyog
A different question, are configure_interaction, generate_content and compare_contents only relevant if we are adding new Generator and Matcher catalogue entries? We aren’t adding those so do we need to worry much about their implementation.Yes, that is correct. You should be able to just ignore anything you don't need, and if your plugin never provides catalogue entries for those types of things, they will never be called.