Contributing to go-watermill-template
April 26, 2022 ยท View on GitHub
First of all, thank you ๐๐พโโ๏ธ for considering contributing to go-watermill-template; it needs all the help it can get!
This contribution guide is an extension to the core contributing guide that can be found here. Please make sure you go through that beforehand. ๐๐๐ฝ
Design
This repo was created from the template repo template-for-generator-templates
It has borrowed most of its concepts from it
Also check out this intial video where some of the concepts about a generator are discussed.
This generator has 2 main concepts
Generated Code
The code generated by this template has the following structure
- asyncapi
- handlers.go
- payloads.go
- publishers.go
- router.go
- server.go
- subscribers.go
- go.mod
- go.sum
- main.go
For each of the above files genenrated there should be a corresponding .js file under the templates direectory.
These template files parse take the parsed asyncapi doc as an input and then delegate to the responsibility of generating code to the react components under the components directory
Development
It is not easy to write code in one language to generate code in another language.
In this case code is being written in js to generate go code.
Hence the best way to develop is to first develop the go code that one intends to generate.
One may consider this repo for example where the working go code is first developed and is used as reference to author the above templates
Dev Testing
In order to dev test the generated code consider running the npm command
npm run dev
This generates go code to the dir output based on the asyncapi sample file here
Once the go code is generated, one can navigate to the output directory and run go run main.go to test the generated code.
Importantly one must have the appropriate broker or messaging software running locally to be able to test it successfully