juju: github.com/juju/juju/apiserver/observer Index | Files | Directories

package observer

import "github.com/juju/juju/apiserver/observer"

Copyright 2016 Canonical Ltd. Licensed under the AGPLv3, see LICENCE file for details.

Index

Package Files

auditfilter.go observer.go recorder.go request_notifier.go

Constants

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
)

func MakeInterestingRequestFilter Uses

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 Uses

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 Uses

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.

type Hub Uses

type Hub interface {
    Publish(topic string, data interface{}) (<-chan struct{}, error)
}

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

type Multiplexer Uses

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

Multiplexer multiplexes calls to an arbitrary number of observers.

func NewMultiplexer Uses

func NewMultiplexer(observers ...Observer) *Multiplexer

NewMultiplexer creates a new Multiplexer with the provided observers.

func None Uses

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 Uses

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 Uses

func (m *Multiplexer) Leave()

Leave implements Observer.

func (*Multiplexer) Login Uses

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

Login implements Observer.

func (*Multiplexer) RPCObserver Uses

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 Uses

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 Uses

type ObserverFactory func() Observer

ObserverFactory is a function which creates an Observer.

func ObserverFactoryMultiplexer Uses

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 Uses

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

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

func NewRequestObserver Uses

func NewRequestObserver(ctx RequestObserverContext) *RequestObserver

NewRequestObserver returns a new RPCObserver.

func (*RequestObserver) Join Uses

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

Join implements Observer.

func (*RequestObserver) Leave Uses

func (n *RequestObserver) Leave()

Leave implements Observer.

func (*RequestObserver) Login Uses

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

Login implements Observer.

func (*RequestObserver) RPCObserver Uses

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

RPCObserver implements Observer.

type RequestObserverContext Uses

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 RequestObserverContext to operate correctly.

Directories

PathSynopsis
fakeobserver
metricobserverPackage metricobserver provides an implementation of apiserver/observer.ObserverFactory that maintains Prometheus metrics.
metricobserver/mocksPackage mocks is a generated GoMock package.

Package observer imports 17 packages (graph) and is imported by 76 packages. Updated 2019-08-26. Refresh now. Tools for package owners.