-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version numbers, update docs, and apply trivial pre-release fixes (
#18)
- Loading branch information
1 parent
f643e33
commit fc3721e
Showing
8 changed files
with
29 additions
and
60 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 |
---|---|---|
@@ -1,31 +1,11 @@ | ||
# Relay Plugins | ||
|
||
The core relay program doesn't include much functionality other than loading plugins and calling into them at appropriate times. Even the main feature of relaying is performed by a plugin! | ||
|
||
## Using plugins | ||
|
||
If you successfully build using `make` then you'll have a `relay-core/dist/plugins/traffic/` directory holding several .so files. These are the plugin files. | ||
|
||
*Load order:* | ||
|
||
Plugins are loaded in alpha-numeric sort order, which is why the default build names the plugins like so: | ||
|
||
- 010-relay.so | ||
- 020-monitor.so | ||
- 030-logging.so | ||
|
||
The order of traffic plugins matters because each plugin is given the opportunity to service incoming requests. The default order lets the relay plugin attempt to relay the request and then the monitor and logging plugins can do their work assuming that the request is handled. | ||
|
||
If you write a plugin then you'll want to name it in such a way that it is loaded in the order that you expect. For example, if you want your plugin to load between the relay and monitor plugins then you'd name it `015-something.so` and because 015 is between 010 and 020 it'll be loaded as expected. | ||
The core relay program's functionality can be extended using plugins. Much of the built-in functionality of the relay is implemented using these plugins, in fact. Plugins are built into the relay binary at compile time, so you don't need to do anything special to load them. | ||
|
||
## Writing plugins | ||
|
||
Relay plugins are implemented as [go plugins](https://github.com/golang/go/wiki/Modules) and that comes with a few tricky bits. The most common error is for a plugin to not expose exactly the expected interface and then fail to load. | ||
|
||
There are three traffic plugins (currently the only plugin type) in the `relay-core` source code that you can use as example code for your plugin: | ||
- [relay](https://github.com/fullstorydev/relay-core/tree/master/go/src/relay/plugins/traffic/relay/main) | ||
- [monitor](https://github.com/fullstorydev/relay-core/tree/master/go/src/relay/plugins/traffic/monitor/main) | ||
- [logging](https://github.com/fullstorydev/relay-core/tree/master/go/src/relay/plugins/traffic/logging/main) | ||
To write a plugin for the relay, you need to write implementations for the [PluginFactory and Plugin interfaces](https://github.com/fullstorydev/relay-core/blob/master/relay/traffic/plugin-interfaces.go). The [built-in plugins](https://github.com/fullstorydev/relay-core/tree/master/relay/plugins/traffic) may serve as a useful starting point. | ||
|
||
To build a plugin you need to use `go build -buildmode=plugin ...` which you can see used in the `plugins` target of Relay's [Makefile](https://github.com/fullstorydev/relay-core/blob/master/Makefile). | ||
Plugins are built and tested as part of the relay code, so you can simply run `make` to build your plugin or `make test` to run its tests. | ||
|
||
To use your new plugin outside of tests, you'll also need to add it to the [DefaultPlugins list](https://github.com/fullstorydev/relay-core/blob/master/relay/main/main.go). This will make the `relay` program load the plugin at startup. |
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
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
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