A small go-lang library that accepts proto file message definitions in protofbuf serialisation format (see proto target in Makefile for how to create these) and a message mapping
and allows transformation from one message to another purely off of these mappings.
Usage
transform_test.go has test cases illustrating usage but in brief
fileDescriptorProto, _ := os.ReadFile("models.pb")
messageMappings := map[string]map[string]string{
"WorkflowState-Compensation": {
"unixTimeNano": "totalSteps",
"elementName": "forTrackingId",
"timer.lastFired": "step",
},
}
transformer, _ := NewTransformer(messageMappings, fileDescriptorProto) // can take multiple fileDescriptor proto files
compensationProtoMessage, err := transform.Transform(workflowStateProtoMessage, "Compensation")
Roadmap
potential improvements:
- the module supports transformations of nested message structures but not nested map or list structures. This might be worth implementing after considering if there are valid use cases.
- add support for golang contexts. The initial cut does not accept a ctx and any of its benefits (like exiting execution on done signal).
License
see LICENSE