-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d024857
commit cacb656
Showing
3 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Contributing to go-watermill-template | ||
|
||
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](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md). Please make sure you go through that beforehand. 🙂👍🏽 | ||
|
||
# Design | ||
|
||
This repo was created from the template repo [template-for-generator-templates](https://github.com/asyncapi/template-for-generator-templates) | ||
|
||
It has borrowed most of its concepts from it | ||
|
||
Also check out this intial [video](https://www.youtube.com/watch?v=0ueeYM_0hck) where some of the concepts about a generator are discussed. | ||
|
||
This generator has 2 main concepts | ||
|
||
1. [template](https://github.com/asyncapi/go-watermill-template/tree/master/template) | ||
2. [components](https://github.com/asyncapi/go-watermill-template/tree/master/components) | ||
|
||
## Generated Code | ||
|
||
The code generated by this template has the following structure | ||
|
||
- __asyncapi__ | ||
- [handlers.go](asyncapi/handlers.go) | ||
- [payloads.go](asyncapi/payloads.go) | ||
- [publishers.go](asyncapi/publishers.go) | ||
- [router.go](asyncapi/router.go) | ||
- [server.go](asyncapi/server.go) | ||
- [subscribers.go](asyncapi/subscribers.go) | ||
- [go.mod](go.mod) | ||
- [go.sum](go.sum) | ||
- [main.go](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](https://github.com/anandsunderraman/watermill-reference) 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](https://github.com/asyncapi/go-watermill-template/blob/master/test/asyncapi.yaml) | ||
|
||
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters