Documentation ¶
Overview ¶
Package extension provides types and functions for creating Sensu extensions in Go. The extensions run as servers and use gRPC as a transport.
Users only need provide a net.Listener, and one or more of the extension methods, to have a fully working Sensu extension. See example for details.
Index ¶
- Variables
- type Extension
- type FilterFunc
- type HandlerFunc
- type Interface
- type MutatorFunc
- type Server
- func (s *Server) FilterEvent(ctx context.Context, req *rpc.FilterEventRequest) (*rpc.FilterEventResponse, error)
- func (s *Server) HandleEvent(ctx context.Context, req *rpc.HandleEventRequest) (*rpc.HandleEventResponse, error)
- func (s *Server) MutateEvent(ctx context.Context, req *rpc.MutateEventRequest) (*rpc.MutateEventResponse, error)
- func (s *Server) Start() error
- func (s *Server) Stop() error
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("method not implemented")
ErrNotImplemented is returned by extension methods that haven't been mapped.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
type Extension struct { HandlerFunc MutatorFunc FilterFunc }
Extension is a convenience type for implementing Interface.
func (*Extension) Filter ¶
func (e *Extension) Filter(fn FilterFunc) *Extension
Filter registers fn as the func to call on FilterEvent.
func (*Extension) Handle ¶
func (e *Extension) Handle(fn HandlerFunc) *Extension
Handle registers fn as the func to call on HandleEvent.
func (*Extension) Mutate ¶
func (e *Extension) Mutate(fn MutatorFunc) *Extension
Mutate registers fn as the func to call on MutateEvent.
type FilterFunc ¶
func (FilterFunc) FilterEvent ¶
func (f FilterFunc) FilterEvent(e *types.Event) (bool, error)
type HandlerFunc ¶
func (HandlerFunc) HandleEvent ¶
func (h HandlerFunc) HandleEvent(e *types.Event, m []byte) error
type Interface ¶
type Interface interface { // FilterEvent filters an event. FilterEvent(*types.Event) (bool, error) // MutateEvent mutates an event. MutateEvent(*types.Event) ([]byte, error) // HandleEvent handles an event. It is passed both the original event // and the mutated event, if the event was mutated. HandleEvent(*types.Event, []byte) error }
Interface is the definition of an extension.
type MutatorFunc ¶
func (MutatorFunc) MutateEvent ¶
func (m MutatorFunc) MutateEvent(e *types.Event) ([]byte, error)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a Sensu extension.
Create new extensions that will run on a local port with NewServer, and then supply any of HandlerFunc, MutatorFunc or FilterFunc via the Handler Mutator
func (*Server) FilterEvent ¶
func (s *Server) FilterEvent(ctx context.Context, req *rpc.FilterEventRequest) (*rpc.FilterEventResponse, error)
FilterEvent is called by gRPC.
func (*Server) HandleEvent ¶
func (s *Server) HandleEvent(ctx context.Context, req *rpc.HandleEventRequest) (*rpc.HandleEventResponse, error)
HandleEvent is called by gRPC.
func (*Server) MutateEvent ¶
func (s *Server) MutateEvent(ctx context.Context, req *rpc.MutateEventRequest) (*rpc.MutateEventResponse, error)
MutateEvent is called by gRPC.