plugins

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCountPlugin

func NewCountPlugin(runner func(Plugin) error) *cobra.Command

NewCountPlugin counts events and number of issues in given state, and for how long.

Types

type ActiveState

type ActiveState struct {
	// contains filtered or unexported fields
}

ActiveState describe a states that has been enabled.

func (ActiveState) Active

func (ActiveState) Active() bool

Active if always true for an ActiveState

func (*ActiveState) Age

func (a *ActiveState) Age(t time.Time) time.Duration

Age gives the time since the state has been activated.

func (*ActiveState) ReceiveEvent

func (a *ActiveState) ReceiveEvent(eventName, label string, t time.Time) (State, bool)

ReceiveEvent checks if the event matches the exit criteria. Returns a new InactiveState or self, and true if it changed.

type AuthorFilterPluginWrapper

type AuthorFilterPluginWrapper struct {
	// contains filtered or unexported fields
}

AuthorFilterPluginWrapper ignore comments and events from some authors

func NewAuthorFilterPluginWrapper

func NewAuthorFilterPluginWrapper(plugin Plugin) *AuthorFilterPluginWrapper

NewAuthorFilterPluginWrapper is the constructor for AuthorFilterPluginWrapper

func (*AuthorFilterPluginWrapper) AddFlags

func (a *AuthorFilterPluginWrapper) AddFlags(cmd *cobra.Command)

AddFlags adds "ignore-authors" <authors> to the command help

func (*AuthorFilterPluginWrapper) ReceiveComment

func (a *AuthorFilterPluginWrapper) ReceiveComment(comment sql.Comment) []Point

ReceiveComment calls plugin.ReceiveComment() if the author is not filtered

func (*AuthorFilterPluginWrapper) ReceiveIssue

func (a *AuthorFilterPluginWrapper) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue calls plugin.ReceiveIssue() if the author is not filtered

func (*AuthorFilterPluginWrapper) ReceiveIssueEvent

func (a *AuthorFilterPluginWrapper) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent calls plugin.ReceiveIssueEvent() if the author is not filtered

type AuthorLoggerPluginWrapper

type AuthorLoggerPluginWrapper struct {
	// contains filtered or unexported fields
}

AuthorLoggerPluginWrapper logs the author on all the Points returned. This is enabled by command-line.

func NewAuthorLoggerPluginWrapper

func NewAuthorLoggerPluginWrapper(plugin Plugin) *AuthorLoggerPluginWrapper

NewAuthorLoggerPluginWrapper is the constructor for AuthorLoggerPluginWrapper

func (*AuthorLoggerPluginWrapper) AddFlags

func (a *AuthorLoggerPluginWrapper) AddFlags(cmd *cobra.Command)

AddFlags adds "log-authors" <authors> to the command help

func (*AuthorLoggerPluginWrapper) ReceiveComment

func (a *AuthorLoggerPluginWrapper) ReceiveComment(comment sql.Comment) []Point

ReceiveComment is a wrapper on plugin.ReceiveComment() logging the author

func (*AuthorLoggerPluginWrapper) ReceiveIssue

func (a *AuthorLoggerPluginWrapper) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is a wrapper on plugin.ReceiveIssue() logging the author

func (*AuthorLoggerPluginWrapper) ReceiveIssueEvent

func (a *AuthorLoggerPluginWrapper) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent is a wrapper on plugin.ReceiveIssueEvent() logging the author

type BundledStates

type BundledStates struct {
	// contains filtered or unexported fields
}

BundledStates saves the state of multiple issues/pull-requests. This will also allow us to then compute statistics on these states like: - Number of pull-requests in activated states (first return value of Total()) - Sum of time since activated pull-requests are activated (second return value of Total()) - Get a specific percentile time for activated pull-requests (Percentile())

func NewBundledStates

func NewBundledStates(description string) BundledStates

NewBundledStates is the constructor for BundledStates

func (BundledStates) Percentile

func (b BundledStates) Percentile(t time.Time, percentile int) time.Duration

Percentile returns given percentile for age of all active states at time t

func (BundledStates) ReceiveEvent

func (b BundledStates) ReceiveEvent(ID string, eventName, label string, t time.Time) bool

ReceiveEvent is called when something happens on an issue. The state for that issue is updated.

func (BundledStates) Total

func (b BundledStates) Total(t time.Time) (count int, sum int64)

Total counts number of active state, and total age (in minutes, to compute average)

type ByDuration

type ByDuration []time.Duration

ByDuration sorts a slice of time.Duration

func (ByDuration) Len

func (b ByDuration) Len() int

func (ByDuration) Less

func (b ByDuration) Less(i, j int) bool

func (ByDuration) Swap

func (b ByDuration) Swap(i, j int)

type CloseEvent

type CloseEvent struct{}

CloseEvent is a "closed" event

func (CloseEvent) Match

func (CloseEvent) Match(eventName, label string) bool

Match is "closed"

func (CloseEvent) Opposite

func (CloseEvent) Opposite() EventMatcher

Opposite is reopen

type CommentCounterPlugin

type CommentCounterPlugin struct {
	// contains filtered or unexported fields
}

CommentCounterPlugin counts comments

func (*CommentCounterPlugin) AddFlags

func (c *CommentCounterPlugin) AddFlags(cmd *cobra.Command)

AddFlags adds "comments" <comments> to the command help

func (*CommentCounterPlugin) CheckFlags

func (c *CommentCounterPlugin) CheckFlags() error

CheckFlags looks for comments matching regexes

func (*CommentCounterPlugin) ReceiveComment

func (c *CommentCounterPlugin) ReceiveComment(comment sql.Comment) []Point

ReceiveComment adds matching comments to InfluxDB

func (CommentCounterPlugin) ReceiveIssue

func (CommentCounterPlugin) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is needed to implement a Plugin

func (CommentCounterPlugin) ReceiveIssueEvent

func (CommentCounterPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent is needed to implement a Plugin

type CommentEvent

type CommentEvent struct{}

CommentEvent is a "commented" event

func (CommentEvent) Match

func (CommentEvent) Match(eventName, label string) bool

Match is "commented"

func (CommentEvent) Opposite

func (CommentEvent) Opposite() EventMatcher

Opposite is false

type DummyPlugin

type DummyPlugin struct{}

DummyPlugin is an empty plugin

func (DummyPlugin) ReceiveComment

func (DummyPlugin) ReceiveComment(comment sql.Comment) []Point

ReceiveComment is needed to implement a Plugin

func (DummyPlugin) ReceiveIssue

func (DummyPlugin) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is needed to implement a Plugin

func (DummyPlugin) ReceiveIssueEvent

func (DummyPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent is needed to implement a Plugin

type EventCounterPlugin

type EventCounterPlugin struct {
	// contains filtered or unexported fields
}

EventCounterPlugin counts events

func (*EventCounterPlugin) AddFlags

func (e *EventCounterPlugin) AddFlags(cmd *cobra.Command)

AddFlags adds "event" to the command help

func (*EventCounterPlugin) CheckFlags

func (e *EventCounterPlugin) CheckFlags() error

CheckFlags is delegated to EventMatcher

func (*EventCounterPlugin) ReceiveComment

func (e *EventCounterPlugin) ReceiveComment(comment sql.Comment) []Point

ReceiveComment is needed to implement a Plugin

func (*EventCounterPlugin) ReceiveIssue

func (e *EventCounterPlugin) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is needed to implement a Plugin

func (*EventCounterPlugin) ReceiveIssueEvent

func (e *EventCounterPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent adds issue events to InfluxDB

type EventMatcher

type EventMatcher interface {
	// Does eventName and label match the event
	Match(eventName, label string) bool
	// Return the opposite of this eventmatcher
	Opposite() EventMatcher
}

EventMatcher generates events based on name and labels

func NewEventMatcher

func NewEventMatcher(eventDescription string) EventMatcher

NewEventMatcher returns the correct EventMatcher based on description Incoming event should have the following form: eventName:labelName. If eventName is not label, then the second part can be omitted.

type EventTimeHeap

type EventTimeHeap []sql.IssueEvent

EventTimeHeap is a min-heap on Event creation time

func (EventTimeHeap) Len

func (t EventTimeHeap) Len() int

func (EventTimeHeap) Less

func (t EventTimeHeap) Less(i, j int) bool

func (*EventTimeHeap) Pop

func (t *EventTimeHeap) Pop() interface{}

Pop retrieves the last added event

func (*EventTimeHeap) Push

func (t *EventTimeHeap) Push(x interface{})

Push adds event to the heap

func (EventTimeHeap) Swap

func (t EventTimeHeap) Swap(i, j int)

type FakeCommentPluginWrapper

type FakeCommentPluginWrapper struct {
	// contains filtered or unexported fields
}

FakeCommentPluginWrapper is a plugin wrapper creating fake "commented" events

func NewFakeCommentPluginWrapper

func NewFakeCommentPluginWrapper(plugin Plugin) *FakeCommentPluginWrapper

NewFakeCommentPluginWrapper is the constructor for FakeCommentPluginWrapper

func (*FakeCommentPluginWrapper) ReceiveComment

func (o *FakeCommentPluginWrapper) ReceiveComment(comment sql.Comment) []Point

ReceiveComment creates a fake "commented" event

func (*FakeCommentPluginWrapper) ReceiveIssue

func (o *FakeCommentPluginWrapper) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is a wrapper on plugin.ReceiveIssue()

func (*FakeCommentPluginWrapper) ReceiveIssueEvent

func (o *FakeCommentPluginWrapper) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent is a wrapper on plugin.ReceiveIssueEvent()

type FakeOpenPluginWrapper

type FakeOpenPluginWrapper struct {
	// contains filtered or unexported fields
}

FakeOpenPluginWrapper sends new "opened" event to ReceiveEvent

func NewFakeOpenPluginWrapper

func NewFakeOpenPluginWrapper(plugin Plugin) *FakeOpenPluginWrapper

NewFakeOpenPluginWrapper is the constructor for FakeOpenPluginWrapper

func (*FakeOpenPluginWrapper) ReceiveComment

func (o *FakeOpenPluginWrapper) ReceiveComment(comment sql.Comment) []Point

ReceiveComment is a wrapper on plugin.ReceiveComment()

func (*FakeOpenPluginWrapper) ReceiveIssue

func (o *FakeOpenPluginWrapper) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue creates a fake "opened" event

func (*FakeOpenPluginWrapper) ReceiveIssueEvent

func (o *FakeOpenPluginWrapper) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent injects an extra "opened" event before calling plugin.ReceiveIssueEvent()

type FalseEvent

type FalseEvent struct{}

FalseEvent is a false event

func (FalseEvent) Match

func (FalseEvent) Match(eventName, label string) bool

Match is false

func (FalseEvent) Opposite

func (FalseEvent) Opposite() EventMatcher

Opposite is true

type InactiveState

type InactiveState struct {
	// contains filtered or unexported fields
}

InactiveState describes a state that has not enabled, or been disabled.

func (InactiveState) Active

func (InactiveState) Active() bool

Active is always false for an InactiveState

func (*InactiveState) Age

func (i *InactiveState) Age(t time.Time) time.Duration

Age doesn't make sense for InactiveState.

func (*InactiveState) ReceiveEvent

func (i *InactiveState) ReceiveEvent(eventName, label string, t time.Time) (State, bool)

ReceiveEvent checks if the event matches the entry criteria Returns a new ActiveState or self, and true if it changed.

type LabelEvent

type LabelEvent struct {
	Label string
}

LabelEvent is a "labeled" event

func (LabelEvent) Match

func (l LabelEvent) Match(eventName, label string) bool

Match is "labeled" with label

func (LabelEvent) Opposite

func (l LabelEvent) Opposite() EventMatcher

Opposite is unlabel

type MergeEvent

type MergeEvent struct{}

MergeEvent is a "merged" event

func (MergeEvent) Match

func (MergeEvent) Match(eventName, label string) bool

Match is "merged"

func (MergeEvent) Opposite

func (MergeEvent) Opposite() EventMatcher

Opposite is false

type MultiState

type MultiState struct {
	// contains filtered or unexported fields
}

MultiState tracks multiple individual states at the same time.

func (*MultiState) Active

func (m *MultiState) Active() bool

Active is true if all the states are active.

func (*MultiState) Age

func (m *MultiState) Age(t time.Time) time.Duration

Age returns the time since all states have been activated. It will panic if any of the state is not active.

func (*MultiState) ReceiveEvent

func (m *MultiState) ReceiveEvent(eventName, label string, t time.Time) (State, bool)

ReceiveEvent will send the event to each individual state, and update them if they change.

type MultiplexerPluginWrapper

type MultiplexerPluginWrapper struct {
	// contains filtered or unexported fields
}

MultiplexerPluginWrapper allows registering multiple plugins for events

func NewMultiplexerPluginWrapper

func NewMultiplexerPluginWrapper(plugins ...Plugin) *MultiplexerPluginWrapper

NewMultiplexerPluginWrapper is the constructor for MultiplexerPluginWrapper

func (*MultiplexerPluginWrapper) ReceiveComment

func (m *MultiplexerPluginWrapper) ReceiveComment(comment sql.Comment) []Point

ReceiveComment calls plugin.ReceiveComment() for all plugins

func (*MultiplexerPluginWrapper) ReceiveIssue

func (m *MultiplexerPluginWrapper) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue calls plugin.ReceiveIssue() for all plugins

func (*MultiplexerPluginWrapper) ReceiveIssueEvent

func (m *MultiplexerPluginWrapper) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent calls plugin.ReceiveIssueEvent() for all plugins

type OpenEvent

type OpenEvent struct{}

OpenEvent is an "opened" event

func (OpenEvent) Match

func (OpenEvent) Match(eventName, label string) bool

Match is "opened"

func (OpenEvent) Opposite

func (OpenEvent) Opposite() EventMatcher

Opposite is closed

type Plugin

type Plugin interface {
	ReceiveIssue(sql.Issue) []Point
	ReceiveComment(sql.Comment) []Point
	ReceiveIssueEvent(sql.IssueEvent) []Point
}

Plugin is the generic interface for metrics stats and measurement. Each metric will be implemented as a Plugin, compute the measurement and push it to the InfluxDatabase. nil Point means there is nothing to return.

type Point

type Point struct {
	Tags   map[string]string
	Values map[string]interface{}
	Date   time.Time
}

Point is what a plugin will return if it wants to insert a new value in db.

type ReopenEvent

type ReopenEvent struct{}

ReopenEvent is a "reopened" event

func (ReopenEvent) Match

func (ReopenEvent) Match(eventName, label string) bool

Match is "reopened"

func (ReopenEvent) Opposite

func (ReopenEvent) Opposite() EventMatcher

Opposite is close

type State

type State interface {
	// Has the state been activated
	Active() bool
	// How long has the state been activated (will panic if not active)
	Age(t time.Time) time.Duration
	// Receive the event, return the new state
	ReceiveEvent(eventName, label string, t time.Time) (State, bool)
}

State describes a pull-request states, based on the events we've seen.

func NewState

func NewState(statesDescription string) State

NewState creates a MultiState instance based on the statesDescription string. statesDescription is a comma separated list of events. Events can be prepended with "!" (bang) to say that the state will be activated only if this event doesn't happen (or is inverted).

type StatePlugin

type StatePlugin struct {
	// contains filtered or unexported fields
}

StatePlugin records age percentiles of issues in InfluxDB

func (*StatePlugin) AddFlags

func (s *StatePlugin) AddFlags(cmd *cobra.Command)

AddFlags adds "state" and "percentiles" to the command help

func (*StatePlugin) CheckFlags

func (s *StatePlugin) CheckFlags() error

CheckFlags configures which states to monitor

func (*StatePlugin) ReceiveComment

func (s *StatePlugin) ReceiveComment(comment sql.Comment) []Point

ReceiveComment is needed to implement a Plugin

func (*StatePlugin) ReceiveIssue

func (s *StatePlugin) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue is needed to implement a Plugin

func (*StatePlugin) ReceiveIssueEvent

func (s *StatePlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent computes age percentiles and saves them to InfluxDB

type TrueEvent

type TrueEvent struct{}

TrueEvent is a true event

func (TrueEvent) Match

func (TrueEvent) Match(eventName, label string) bool

Match is true

func (TrueEvent) Opposite

func (TrueEvent) Opposite() EventMatcher

Opposite is false

type TypeFilterWrapperPlugin

type TypeFilterWrapperPlugin struct {
	// contains filtered or unexported fields
}

TypeFilterWrapperPlugin allows ignoring either PR or issues from processing

func NewTypeFilterWrapperPlugin

func NewTypeFilterWrapperPlugin(plugin Plugin) *TypeFilterWrapperPlugin

NewTypeFilterWrapperPlugin is the constructor of TypeFilterWrapperPlugin

func (*TypeFilterWrapperPlugin) AddFlags

func (t *TypeFilterWrapperPlugin) AddFlags(cmd *cobra.Command)

AddFlags adds "no-pull-requests" and "no-issues" to the command help

func (*TypeFilterWrapperPlugin) CheckFlags

func (t *TypeFilterWrapperPlugin) CheckFlags() error

CheckFlags makes sure not both PR and issues are ignored

func (*TypeFilterWrapperPlugin) ReceiveComment

func (t *TypeFilterWrapperPlugin) ReceiveComment(comment sql.Comment) []Point

ReceiveComment calls plugin.ReceiveComment() if issues are not ignored

func (*TypeFilterWrapperPlugin) ReceiveIssue

func (t *TypeFilterWrapperPlugin) ReceiveIssue(issue sql.Issue) []Point

ReceiveIssue calls plugin.ReceiveIssue() if issues are not ignored

func (*TypeFilterWrapperPlugin) ReceiveIssueEvent

func (t *TypeFilterWrapperPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point

ReceiveIssueEvent calls plugin.ReceiveIssueEvent() if issues are not ignored

type UnlabelEvent

type UnlabelEvent struct {
	Label string
}

UnlabelEvent is an "unlabeled" event

func (UnlabelEvent) Match

func (u UnlabelEvent) Match(eventName, label string) bool

Match is "unlabeled"

func (UnlabelEvent) Opposite

func (u UnlabelEvent) Opposite() EventMatcher

Opposite is label

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL