move plugin interfaces into separate package

This commit is contained in:
David Norton
2016-12-23 10:18:27 -05:00
parent 3e6c4a53a4
commit 81caa56859
182 changed files with 817 additions and 817 deletions

View File

@@ -8,15 +8,15 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type FilestackWebhook struct {
Path string
acc telegraf.Accumulator
acc plugins.Accumulator
}
func (fs *FilestackWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
func (fs *FilestackWebhook) Register(router *mux.Router, acc plugins.Accumulator) {
router.HandleFunc(fs.Path, fs.eventHandler).Methods("POST")
log.Printf("I! Started the webhooks_filestack on %s\n", fs.Path)

View File

@@ -7,15 +7,15 @@ import (
"net/http"
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type GithubWebhook struct {
Path string
acc telegraf.Accumulator
acc plugins.Accumulator
}
func (gh *GithubWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
func (gh *GithubWebhook) Register(router *mux.Router, acc plugins.Accumulator) {
router.HandleFunc(gh.Path, gh.eventHandler).Methods("POST")
log.Printf("I! Started the webhooks_github on %s\n", gh.Path)
gh.acc = acc

View File

@@ -5,14 +5,14 @@ import (
"log"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/metric"
)
const meas = "github_webhooks"
type Event interface {
NewMetric() telegraf.Metric
NewMetric() plugins.Metric
}
type Repository struct {
@@ -91,7 +91,7 @@ type CommitCommentEvent struct {
Sender Sender `json:"sender"`
}
func (s CommitCommentEvent) NewMetric() telegraf.Metric {
func (s CommitCommentEvent) NewMetric() plugins.Metric {
event := "commit_comment"
t := map[string]string{
"event": event,
@@ -121,7 +121,7 @@ type CreateEvent struct {
Sender Sender `json:"sender"`
}
func (s CreateEvent) NewMetric() telegraf.Metric {
func (s CreateEvent) NewMetric() plugins.Metric {
event := "create"
t := map[string]string{
"event": event,
@@ -151,7 +151,7 @@ type DeleteEvent struct {
Sender Sender `json:"sender"`
}
func (s DeleteEvent) NewMetric() telegraf.Metric {
func (s DeleteEvent) NewMetric() plugins.Metric {
event := "delete"
t := map[string]string{
"event": event,
@@ -180,7 +180,7 @@ type DeploymentEvent struct {
Sender Sender `json:"sender"`
}
func (s DeploymentEvent) NewMetric() telegraf.Metric {
func (s DeploymentEvent) NewMetric() plugins.Metric {
event := "deployment"
t := map[string]string{
"event": event,
@@ -212,7 +212,7 @@ type DeploymentStatusEvent struct {
Sender Sender `json:"sender"`
}
func (s DeploymentStatusEvent) NewMetric() telegraf.Metric {
func (s DeploymentStatusEvent) NewMetric() plugins.Metric {
event := "delete"
t := map[string]string{
"event": event,
@@ -245,7 +245,7 @@ type ForkEvent struct {
Sender Sender `json:"sender"`
}
func (s ForkEvent) NewMetric() telegraf.Metric {
func (s ForkEvent) NewMetric() plugins.Metric {
event := "fork"
t := map[string]string{
"event": event,
@@ -274,7 +274,7 @@ type GollumEvent struct {
}
// REVIEW: Going to be lazy and not deal with the pages.
func (s GollumEvent) NewMetric() telegraf.Metric {
func (s GollumEvent) NewMetric() plugins.Metric {
event := "gollum"
t := map[string]string{
"event": event,
@@ -302,7 +302,7 @@ type IssueCommentEvent struct {
Sender Sender `json:"sender"`
}
func (s IssueCommentEvent) NewMetric() telegraf.Metric {
func (s IssueCommentEvent) NewMetric() plugins.Metric {
event := "issue_comment"
t := map[string]string{
"event": event,
@@ -334,7 +334,7 @@ type IssuesEvent struct {
Sender Sender `json:"sender"`
}
func (s IssuesEvent) NewMetric() telegraf.Metric {
func (s IssuesEvent) NewMetric() plugins.Metric {
event := "issue"
t := map[string]string{
"event": event,
@@ -365,7 +365,7 @@ type MemberEvent struct {
Sender Sender `json:"sender"`
}
func (s MemberEvent) NewMetric() telegraf.Metric {
func (s MemberEvent) NewMetric() plugins.Metric {
event := "member"
t := map[string]string{
"event": event,
@@ -395,7 +395,7 @@ type MembershipEvent struct {
Team Team `json:"team"`
}
func (s MembershipEvent) NewMetric() telegraf.Metric {
func (s MembershipEvent) NewMetric() plugins.Metric {
event := "membership"
t := map[string]string{
"event": event,
@@ -419,7 +419,7 @@ type PageBuildEvent struct {
Sender Sender `json:"sender"`
}
func (s PageBuildEvent) NewMetric() telegraf.Metric {
func (s PageBuildEvent) NewMetric() plugins.Metric {
event := "page_build"
t := map[string]string{
"event": event,
@@ -445,7 +445,7 @@ type PublicEvent struct {
Sender Sender `json:"sender"`
}
func (s PublicEvent) NewMetric() telegraf.Metric {
func (s PublicEvent) NewMetric() plugins.Metric {
event := "public"
t := map[string]string{
"event": event,
@@ -473,7 +473,7 @@ type PullRequestEvent struct {
Sender Sender `json:"sender"`
}
func (s PullRequestEvent) NewMetric() telegraf.Metric {
func (s PullRequestEvent) NewMetric() plugins.Metric {
event := "pull_request"
t := map[string]string{
"event": event,
@@ -510,7 +510,7 @@ type PullRequestReviewCommentEvent struct {
Sender Sender `json:"sender"`
}
func (s PullRequestReviewCommentEvent) NewMetric() telegraf.Metric {
func (s PullRequestReviewCommentEvent) NewMetric() plugins.Metric {
event := "pull_request_review_comment"
t := map[string]string{
"event": event,
@@ -549,7 +549,7 @@ type PushEvent struct {
Sender Sender `json:"sender"`
}
func (s PushEvent) NewMetric() telegraf.Metric {
func (s PushEvent) NewMetric() plugins.Metric {
event := "push"
t := map[string]string{
"event": event,
@@ -579,7 +579,7 @@ type ReleaseEvent struct {
Sender Sender `json:"sender"`
}
func (s ReleaseEvent) NewMetric() telegraf.Metric {
func (s ReleaseEvent) NewMetric() plugins.Metric {
event := "release"
t := map[string]string{
"event": event,
@@ -606,7 +606,7 @@ type RepositoryEvent struct {
Sender Sender `json:"sender"`
}
func (s RepositoryEvent) NewMetric() telegraf.Metric {
func (s RepositoryEvent) NewMetric() plugins.Metric {
event := "repository"
t := map[string]string{
"event": event,
@@ -634,7 +634,7 @@ type StatusEvent struct {
Sender Sender `json:"sender"`
}
func (s StatusEvent) NewMetric() telegraf.Metric {
func (s StatusEvent) NewMetric() plugins.Metric {
event := "status"
t := map[string]string{
"event": event,
@@ -663,7 +663,7 @@ type TeamAddEvent struct {
Sender Sender `json:"sender"`
}
func (s TeamAddEvent) NewMetric() telegraf.Metric {
func (s TeamAddEvent) NewMetric() plugins.Metric {
event := "team_add"
t := map[string]string{
"event": event,
@@ -690,7 +690,7 @@ type WatchEvent struct {
Sender Sender `json:"sender"`
}
func (s WatchEvent) NewMetric() telegraf.Metric {
func (s WatchEvent) NewMetric() plugins.Metric {
event := "delete"
t := map[string]string{
"event": event,

View File

@@ -9,15 +9,15 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type MandrillWebhook struct {
Path string
acc telegraf.Accumulator
acc plugins.Accumulator
}
func (md *MandrillWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
func (md *MandrillWebhook) Register(router *mux.Router, acc plugins.Accumulator) {
router.HandleFunc(md.Path, md.returnOK).Methods("HEAD")
router.HandleFunc(md.Path, md.eventHandler).Methods("POST")

View File

@@ -9,15 +9,15 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type RollbarWebhook struct {
Path string
acc telegraf.Accumulator
acc plugins.Accumulator
}
func (rb *RollbarWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
func (rb *RollbarWebhook) Register(router *mux.Router, acc plugins.Accumulator) {
router.HandleFunc(rb.Path, rb.eventHandler).Methods("POST")
log.Printf("I! Started the webhooks_rollbar on %s\n", rb.Path)
rb.acc = acc

View File

@@ -7,7 +7,7 @@ import (
"reflect"
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/inputs/webhooks/filestack"
@@ -17,11 +17,11 @@ import (
)
type Webhook interface {
Register(router *mux.Router, acc telegraf.Accumulator)
Register(router *mux.Router, acc plugins.Accumulator)
}
func init() {
inputs.Add("webhooks", func() telegraf.Input { return NewWebhooks() })
inputs.Add("webhooks", func() plugins.Input { return NewWebhooks() })
}
type Webhooks struct {
@@ -60,11 +60,11 @@ func (wb *Webhooks) Description() string {
return "A Webhooks Event collector"
}
func (wb *Webhooks) Gather(_ telegraf.Accumulator) error {
func (wb *Webhooks) Gather(_ plugins.Accumulator) error {
return nil
}
func (wb *Webhooks) Listen(acc telegraf.Accumulator) {
func (wb *Webhooks) Listen(acc plugins.Accumulator) {
r := mux.NewRouter()
for _, webhook := range wb.AvailableWebhooks() {
@@ -98,7 +98,7 @@ func (wb *Webhooks) AvailableWebhooks() []Webhook {
return webhooks
}
func (wb *Webhooks) Start(acc telegraf.Accumulator) error {
func (wb *Webhooks) Start(acc plugins.Accumulator) error {
go wb.Listen(acc)
log.Printf("I! Started the webhooks service on %s\n", wb.ServiceAddress)
return nil