observer

package
v0.0.0-...-e653fdf Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 17 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// CaptureArgs means we'll serialize the API arguments and store
	// them in the audit log.
	CaptureArgs = true

	// NoCaptureArgs means don't do that.
	NoCaptureArgs = false
)

Variables

This section is empty.

Functions

func MakeInterestingRequestFilter

func MakeInterestingRequestFilter(excludeMethods set.Strings) func(auditlog.Request) bool

MakeInterestingRequestFilter takes a set of method names (as facade.method, e.g. "Client.FullStatus") that aren't very interesting from an auditing perspective, and returns a filter function for audit logging that will mark the request as interesting if it's a call to a method that isn't listed. If one of the entries is "ReadOnlyMethods", any method matching the fixed list of read-only methods below will also be considered uninteresting.

func NewAuditLogFilter

func NewAuditLogFilter(log auditlog.AuditLog, filter func(auditlog.Request) bool) auditlog.AuditLog

NewAuditLogFilter returns an auditlog.AuditLog that will only log conversations to the underlying log passed in if they include a request that satisfies the filter function passed in.

func NewRecorderFactory

func NewRecorderFactory(
	observerFactory rpc.ObserverFactory,
	recorder *auditlog.Recorder,
	captureArgs bool,
) rpc.RecorderFactory

NewRecorderFactory makes a new rpc.RecorderFactory to make recorders that that will update the observer and the auditlog recorder when it records a request or reply. The auditlog recorder can be nil.

Types

type Hub

type Hub interface {
	Publish(topic string, data interface{}) (func(), error)
}

Hub defines the only method of the apiserver centralhub that the observer uses.

type Multiplexer

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

Multiplexer multiplexes calls to an arbitrary number of observers.

func NewMultiplexer

func NewMultiplexer(observers ...Observer) *Multiplexer

NewMultiplexer creates a new Multiplexer with the provided observers.

func None

func None() *Multiplexer

None is a wrapper around the Multiplexer factory to add clarity to code that doesn't need any observers.

func (*Multiplexer) Join

func (m *Multiplexer) Join(req *http.Request, connectionID uint64)

Join is called when the connection to the API server's WebSocket is opened.

func (*Multiplexer) Leave

func (m *Multiplexer) Leave()

Leave implements Observer.

func (*Multiplexer) Login

func (m *Multiplexer) Login(entity names.Tag, model names.ModelTag, fromController bool, userData string)

Login implements Observer.

func (*Multiplexer) RPCObserver

func (m *Multiplexer) RPCObserver() rpc.Observer

RPCObserver implements Observer. It will create an rpc.ObserverMultiplexer by calling all the Observer's RPCObserver methods.

type Observer

type Observer interface {
	rpc.ObserverFactory

	// Login informs an Observer that an entity has logged in.
	Login(entity names.Tag, model names.ModelTag, fromController bool, userData string)

	// Join is called when the connection to the API server's
	// WebSocket is opened.
	Join(req *http.Request, connectionID uint64)

	// Leave is called when the connection to the API server's
	// WebSocket is closed.
	Leave()
}

Observer defines a type which will observe API server events as they happen.

type ObserverFactory

type ObserverFactory func() Observer

ObserverFactory is a function which creates an Observer.

func ObserverFactoryMultiplexer

func ObserverFactoryMultiplexer(factories ...ObserverFactory) ObserverFactory

ObserverFactoryMultiplexer returns an ObserverFactory which will return a Multiplexer of all the observers instantiated from the factories passed in.

type RequestObserver

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

RequestObserver serves as a sink for API server requests and responses.

func NewRequestObserver

func NewRequestObserver(ctx RequestObserverContext) *RequestObserver

NewRequestObserver returns a new RPCObserver.

func (*RequestObserver) Join

func (n *RequestObserver) Join(req *http.Request, connectionID uint64)

Join implements Observer.

func (*RequestObserver) Leave

func (n *RequestObserver) Leave()

Leave implements Observer.

func (*RequestObserver) Login

func (n *RequestObserver) Login(entity names.Tag, model names.ModelTag, fromController bool, userData string)

Login implements Observer.

func (*RequestObserver) RPCObserver

func (n *RequestObserver) RPCObserver() rpc.Observer

RPCObserver implements Observer.

type RequestObserverContext

type RequestObserverContext struct {

	// Clock is the clock to use for all time operations on this type.
	Clock clock.Clock

	// Hub refers to the pubsub Hub which will have connection
	// and disconnection events published.
	Hub Hub

	// Logger is the log to use to write log statements.
	Logger loggo.Logger
}

RequestObserverContext provides information needed for a RequestObserver to operate correctly.

Directories

Path Synopsis
Package metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
Package metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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