Stanislav Vodetskyi
12/05/2023, 12:09 AM[]byte
objects, so the actual payload could be json, protobuf or avro, the particular example I'm looking at is with value and some of the headers encoded as protos.
• I don't think I can use pact-protobuf
plugin since it's not a single proto message that I'm sending, but a combination of string key, a map of string to string/proto as headers and a proto value.
• I don't think there's a good way to express such contracts in Pact; I was thinking of writing some sort of a plugin that would accept configuration like this one, but ideally if it deals with e.g. protos it should refer to pact-protobuf plugin for data conversion, ie I don't want to rewrite half of that plugin inside this one.
{
"key": "abc",
"keyType": "string",
"keyProto": null, // only necessary when key is protobuf
"value": {...},
"valueType": "proto",
"valueProto": "MyProtoMessage",
"headers": [
{
"name": "whatever",
"type": "string",
"value": "some value",
"proto": null
}
]
}
• I could probably craft a separate proto representing just the kafka message specific for this service, ie where value and headers are typed, and use pact-protobuf plugin, but I'm not sure it'll deal well with headers of different types either; though that could probably be a lesser issue, maybe even refactor on the product side
• Maybe I'm tackling this from the wrong direction completely, wdyt?
• Thanks! 🙂Stanislav Vodetskyi
12/05/2023, 12:15 AMMatt (pactflow.io / pact-js / pact-go)
Stanislav Vodetskyi
12/07/2023, 12:13 AMMatt (pactflow.io / pact-js / pact-go)
Stanislav Vodetskyi
12/07/2023, 7:54 PMMatt (pactflow.io / pact-js / pact-go)
rholshausen
12/07/2023, 10:01 PMStanislav Vodetskyi
12/07/2023, 11:28 PMCurrently the bodies in Pact are considered a single “content type”. It sounds like you need a Kafka message specific plugin, that can delegate content-type matching for fields of different typesI'm wondering if I can bypass this whole conundrum by putting key and headers in metadata, and kafka value in a body of the request. I mean currently that's how http works - contract consists of the body, but also additional data like url, query params, headers etc; I wonder if I just put all extra data in metadata in async pact too, that might work
Matt (pactflow.io / pact-js / pact-go)