Closed mochi-co closed 8 months ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
config/config.go | 71 | 78 | 91.03% | ||
<!-- | Total: | 144 | 151 | 95.36% | --> |
Totals | |
---|---|
Change from base Build 8319335138: | -0.06% |
Covered Lines: | 5692 |
Relevant Lines: | 5772 |
@mochi-co great job carrying on the work! I'll take a look at this asap.
Following our discussions and @dgduncan's work in #309, here is a PR which implements a new file-based configuration for the broker.
A runnable example can be found in
examples/config
.How it works Rather creating a layer which adds listeners and hooks as they are in the main.go files, I have opted instead to update the hooks and listeners so that they can be applied directly through the server options.
The server options, capabilities, and compatibilities transfer directly from yaml/json into their normal options struct, as though it were being provided as a value created in main.go. Refer to
examples/config/config.yaml
(orconfig.json
) for all options.The listeners are defined using a slice Listener.Config, specifying the Type, ID, and Address. TLS can also be specified although I haven't tried it, so it may need a bit of work.
Hooks are defined individually, and split by category. As above, see config.yaml for a full list of options for each hook. This was a bit tricky to implement in a respectable manner, but in the end I decided to simply give hooks their own configuration struct, and allow only one type of each hook, which allows us to provide custom parameters for each (e.g. Auth and Storage.Redis).
I have updated the Dockerfile and added a
cmd/docker.main.go
as per @dgduncan's original work. I have not tested it.Caveats
Contains breaking changes for the way listeners are initialized (id and address are now in Config).
If you wish to use custom hooks and listeners, you will currently need to modify the code to support these, or just use the standard system of applying them in a custom go file.
I suspect I've missed some edge-cases too, but thought I'd submit it for review :)