Expand description
Support for Pact plugins written in Lua.
A Lua plugin is loaded as an embedded mlua interpreter running in the driver’s own
process (executableType: "lua" in pact-plugin.json), instead of a separate child
process speaking gRPC. The plugin script must define these global functions:
init(implementation, version) -> table- returns an array of catalogue entries, each shaped as{ entryType = "CONTENT_MATCHER", key = "...", values = { ... } }.configure_interaction(content_type, config) -> table- seePluginInstance::configure_interaction.match_contents(request) -> table- seePluginInstance::compare_contents.generate_content(contents, generators, test_mode)(optional) - seePluginInstance::generate_content.update_catalogue(catalogue)(optional) - seePluginInstance::update_catalogue.
A Lua plugin that registers a TRANSPORT catalogue entry (instead of, or as well as, a
CONTENT_MATCHER/CONTENT_GENERATOR one) must also define these functions. The plugin
itself is responsible for whatever the transport actually requires (opening sockets,
making outbound calls, etc.) - the driver only calls these functions at the right points
in the test lifecycle, exactly as it would over gRPC for an exec plugin:
start_mock_server(request) -> table- seePluginInstance::start_mock_server/PluginInstance::start_mock_server_v2.shutdown_mock_server(server_key) -> table- seePluginInstance::shutdown_mock_server.get_mock_server_results(server_key) -> table- seePluginInstance::get_mock_server_results.prepare_interaction_for_verification(request) -> table- seePluginInstance::prepare_interaction_for_verification/PluginInstance::prepare_interaction_for_verification_v2.verify_interaction(request) -> table- seePluginInstance::verify_interaction/PluginInstance::verify_interaction_v2.
Each of these is called with either a V1-shaped or a V2-shaped request table, never both,
depending on the plugin’s own pluginInterfaceVersion in its manifest - the same static,
per-instance choice the driver makes for gRPC plugins (see plugin_manager.rs).
Structs§
- LuaPact
Plugin - A running Lua plugin instance. Each instance owns its own embedded Lua VM.