plugins

package
v0.0.0-...-5952ad4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 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

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
}

func NewAuthorFilterPluginWrapper

func NewAuthorFilterPluginWrapper(plugin Plugin) *AuthorFilterPluginWrapper

func (*AuthorFilterPluginWrapper) AddFlags

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

func (*AuthorFilterPluginWrapper) ReceiveComment

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

func (*AuthorFilterPluginWrapper) ReceiveIssue

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

func (*AuthorFilterPluginWrapper) ReceiveIssueEvent

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

type AuthorLoggerPluginWrapper

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

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

func NewAuthorLoggerPluginWrapper

func NewAuthorLoggerPluginWrapper(plugin Plugin) *AuthorLoggerPluginWrapper

func (*AuthorLoggerPluginWrapper) AddFlags

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

func (*AuthorLoggerPluginWrapper) ReceiveComment

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

func (*AuthorLoggerPluginWrapper) ReceiveIssue

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

func (*AuthorLoggerPluginWrapper) ReceiveIssueEvent

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

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 creates a new 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{}

func (CloseEvent) Match

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

func (CloseEvent) Opposite

func (CloseEvent) Opposite() EventMatcher

type CommentCounterPlugin

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

func (*CommentCounterPlugin) AddFlags

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

func (*CommentCounterPlugin) CheckFlags

func (c *CommentCounterPlugin) CheckFlags() error

func (*CommentCounterPlugin) ReceiveComment

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

func (CommentCounterPlugin) ReceiveIssue

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

func (CommentCounterPlugin) ReceiveIssueEvent

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

type CommentEvent

type CommentEvent struct{}

func (CommentEvent) Match

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

func (CommentEvent) Opposite

func (CommentEvent) Opposite() EventMatcher

type DummyPlugin

type DummyPlugin struct{}

func (DummyPlugin) ReceiveComment

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

func (DummyPlugin) ReceiveIssue

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

func (DummyPlugin) ReceiveIssueEvent

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

type EventCounterPlugin

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

func (*EventCounterPlugin) AddFlags

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

func (*EventCounterPlugin) CheckFlags

func (e *EventCounterPlugin) CheckFlags() error

func (*EventCounterPlugin) ReceiveComment

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

func (*EventCounterPlugin) ReceiveIssue

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

func (*EventCounterPlugin) ReceiveIssueEvent

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

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
}

func NewEventMatcher

func NewEventMatcher(eventDescription string) EventMatcher

Incoming event should have the following form: eventName:labelName. If eventName is not label, then the second part can be ommitted.

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{}

func (*EventTimeHeap) Push

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

func (EventTimeHeap) Swap

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

type FakeCommentPluginWrapper

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

func NewFakeCommentPluginWrapper

func NewFakeCommentPluginWrapper(plugin Plugin) *FakeCommentPluginWrapper

func (*FakeCommentPluginWrapper) ReceiveComment

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

func (*FakeCommentPluginWrapper) ReceiveIssue

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

func (*FakeCommentPluginWrapper) ReceiveIssueEvent

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

type FakeOpenPluginWrapper

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

FakeOpenPluginWrapper sends new "opened" event to ReceiveEvent

func NewFakeOpenPluginWrapper

func NewFakeOpenPluginWrapper(plugin Plugin) *FakeOpenPluginWrapper

func (*FakeOpenPluginWrapper) ReceiveComment

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

func (*FakeOpenPluginWrapper) ReceiveIssue

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

func (*FakeOpenPluginWrapper) ReceiveIssueEvent

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

type FalseEvent

type FalseEvent struct{}

func (FalseEvent) Match

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

func (FalseEvent) Opposite

func (FalseEvent) Opposite() EventMatcher

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
}

func (LabelEvent) Match

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

func (LabelEvent) Opposite

func (l LabelEvent) Opposite() EventMatcher

type MergeEvent

type MergeEvent struct{}

func (MergeEvent) Match

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

func (MergeEvent) Opposite

func (MergeEvent) Opposite() EventMatcher

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
}

func NewMultiplexerPluginWrapper

func NewMultiplexerPluginWrapper(plugins ...Plugin) *MultiplexerPluginWrapper

func (*MultiplexerPluginWrapper) ReceiveComment

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

func (*MultiplexerPluginWrapper) ReceiveIssue

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

func (*MultiplexerPluginWrapper) ReceiveIssueEvent

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

type OpenEvent

type OpenEvent struct{}

func (OpenEvent) Match

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

func (OpenEvent) Opposite

func (OpenEvent) Opposite() EventMatcher

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{}

func (ReopenEvent) Match

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

func (ReopenEvent) Opposite

func (ReopenEvent) Opposite() EventMatcher

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
}

func (*StatePlugin) AddFlags

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

func (*StatePlugin) CheckFlags

func (s *StatePlugin) CheckFlags() error

func (*StatePlugin) ReceiveComment

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

func (*StatePlugin) ReceiveIssue

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

func (*StatePlugin) ReceiveIssueEvent

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

type TrueEvent

type TrueEvent struct{}

func (TrueEvent) Match

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

func (TrueEvent) Opposite

func (TrueEvent) Opposite() EventMatcher

type TypeFilterWrapperPlugin

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

func NewTypeFilterWrapperPlugin

func NewTypeFilterWrapperPlugin(plugin Plugin) *TypeFilterWrapperPlugin

func (*TypeFilterWrapperPlugin) AddFlags

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

func (*TypeFilterWrapperPlugin) CheckFlags

func (t *TypeFilterWrapperPlugin) CheckFlags() error

func (*TypeFilterWrapperPlugin) ReceiveComment

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

func (*TypeFilterWrapperPlugin) ReceiveIssue

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

func (*TypeFilterWrapperPlugin) ReceiveIssueEvent

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

type UnlabelEvent

type UnlabelEvent struct {
	Label string
}

func (UnlabelEvent) Match

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

func (UnlabelEvent) Opposite

func (u UnlabelEvent) Opposite() EventMatcher

Jump to

Keyboard shortcuts

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