observer

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

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

Audit is an observer which will log APIServer requests using the function provided.

func NewAudit

func NewAudit(ctx *AuditContext, handleAuditEntry audit.AuditEntrySinkFn, errorHandler ErrorHandler) *Audit

NewAudit creates a new Audit with the information provided via the Context.

func (*Audit) Join

func (a *Audit) Join(req *http.Request, _ uint64)

Join implements Observer.

func (*Audit) Leave

func (a *Audit) Leave()

Leave implements Observer.

func (*Audit) Login

func (a *Audit) Login(entity names.Tag, _ names.ModelTag, _ bool, _ string)

Login implements Observer.

func (*Audit) RPCObserver

func (a *Audit) RPCObserver() rpc.Observer

RPCObserver implements Observer.

type AuditContext

type AuditContext struct {

	// JujuServerVersion is the version of jujud.
	JujuServerVersion version.Number

	// ModelUUID is the UUID of the model the audit observer is
	// currently running on.
	ModelUUID string
}

Context defines things an Audit observer need know about to operate correctly.

type AuditRPCObserver

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

AuditRPCObserver is an observer which will log RPC requests using the function provided.

func (*AuditRPCObserver) ServerReply

func (a *AuditRPCObserver) ServerReply(rpc.Request, *rpc.Header, interface{})

ServerReply implements Observer.

func (*AuditRPCObserver) ServerRequest

func (a *AuditRPCObserver) ServerRequest(hdr *rpc.Header, body interface{})

ServerRequest implements Observer.

type ErrorHandler

type ErrorHandler func(error)

type Multiplexer

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

Multiplexer multiplexes calls to an arbitray 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, _ names.ModelTag, _ bool, _ 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

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

RequestObservercontext provides information needed for a RequestObserverContext to operate correctly.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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