Backend¶
Project Setup¶
Backend microservices are written in Go (with module support, minimal Go lang required is 1.11), this is how you can get started writing your own:
Create a fork of the project from GitHub
- Create a base directory to check out the project into e.g.
/Development/go/moira/
- Set your GOPATH to that directory and change into it
export GOPATH=/Development/go/moira/ cd $GOPATH
- Get GoConvey for tests
go get github.com/smartystreets/goconvey
- Export your
GOPATH
’sbin
directory export PATH=$PATH:$GOPATH/bin
- Export your
- Checkout your Moira clone into the root of the
GOPATH
git clone https://github.com/<your username>/moira $GOPATH/src/github.com/moira-alert/moira
- Checkout your Moira clone into the root of the
Go into
$GOPATH/src/github.com/moira-alert/moira
- Launch GoConvey
goconvey
You are now ready to start hacking. Goconvey will keep running in the background, scanning for new test classes to execute. If you don’t want to run the entire suite, start Goconvey from the root of directory you will be developing your code from.
Alternatively you can run a quick test on the terminal with
go test -v
Writing Your Own Notification Sender¶
First, look at built-in senders:
senders/slack
senders/pushover
senders/mail
All of them implement interface Sender
from interfaces.go
.
Please, note that scheduling and throttling require senders to support
packing several events into one message.
You should include your new sender in RegisterSenders
method of notifier/registrator.go
with appropriate type.
Senders have access to their settings in common config,
which is passed to the Init
method.