Skip to content

Commit a35be54

Browse files
author
Thomas Poignant
committed
add documentation page
1 parent a639f46 commit a35be54

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/notifier/custom.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Custom Notifier
2+
To create a custom notifier you must have a `struct` that implements the [`ffnotifier.notifier`](https://pkg.go.dev/github.com/thomaspoignant/go-feature-flag/ffnotifier/notifier) interface.
3+
4+
```go linenums="1"
5+
import (
6+
"fmt"
7+
ffclient "github.com/thomaspoignant/go-feature-flag"
8+
"github.com/thomaspoignant/go-feature-flag/ffnotifier"
9+
"sync"
10+
)
11+
12+
// Your config object to create a new Notifier
13+
type CustomNotifierConfig struct{}
14+
15+
// GetNotifier returns a notfier that implement ffnotifier.Notifier
16+
func (c *CustomNotifier) GetNotifier(config ffclient.Config) (ffnotifier.Notifier, error) {
17+
return &CustomNotifier{}, nil
18+
}
19+
20+
type CustomNotifier struct{}
21+
func (w *CustomNotifier) Notify(cache ffnotifier.DiffCache, waitGroup *sync.WaitGroup) {
22+
defer waitGroup.Done() // don't forget this line, if you don't have it you can break your notifications
23+
24+
// ...
25+
// do whatever you want here
26+
}
27+
```

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ nav:
8282
- 'notifier/index.md'
8383
- 'notifier/slack.md'
8484
- 'notifier/webhook.md'
85+
- 'notifier/custom.md'
8586
- 'faq.md'

0 commit comments

Comments
 (0)