eventlog

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeploymentNotFound = errors.New("deployment ID not found")

ErrDeploymentNotFound is returned when the deployment ID is not found in a PointerRegistry.

Functions

This section is empty.

Types

type Appender

type Appender interface {
	// Append appends Event to event log and returns its ID.
	Append(event Event) (string, error)
}

Appender is writer to append only event log.

type Clearer

type Clearer interface {
	Clear(id string) error
}

Clearer is interface used to clear state of event log

type ErrUseNewOlympus

type ErrUseNewOlympus struct {
	Endpoint string
}

ErrUseNewOlympus is error raise on redirect from global dns entry to specific deployment

func (*ErrUseNewOlympus) Error

func (e *ErrUseNewOlympus) Error() string

type Event

type Event struct {
	// ID is identifier, also used as a pointer reference target.
	ID string `json:"_id" bson:"_id,omitempty"`
	// Op is the operation on the event log. Valid values are "ADD"
	// TODO: add support for "DEL"
	Op EventOp `json:"op" bson:"op"`
	// Time is cache-miss created/handled time.
	Time time.Time `json:"time_created" bson:"time_created"`
	// Module is module name.
	Module string `json:"module" bson:"module"`
	// Version is version of a module e.g. "1.10", "1.10-deprecated"
	Version string `json:"version" bson:"version"`
}

Event is entry of event log specifying demand for a module. It implements json.Marshaler

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

MarshalJSON conforms to json.Marshaler

type EventOp

type EventOp string

EventOp holds an operation type on an event

const (
	// OpAdd represents an add event
	OpAdd EventOp = "ADD"
	// OpDel represents a delete event
	OpDel EventOp = "DEL"
	// OpDep represents a deprecate event
	OpDep EventOp = "DEP"
)

type Eventlog

type Eventlog interface {
	Reader
	Appender
	Clearer
}

Eventlog is append only log of Events.

type PointerRegistry

type PointerRegistry interface {
	// LookupPointer returns an event log pointer for the given deployment ID.
	LookupPointer(deploymentID string) (string, error)
	// SetPointer records the current event log pointer for the given deployment ID.
	SetPointer(deploymentID, pointer string) error
}

PointerRegistry is a key/value store that stores an event log pointer for one or more Olympus deployments. It is used in proxies (Athens) and Olympus deployments as part of the event log sync process

type Reader

type Reader interface {
	// Read reads all events in event log.
	Read() ([]Event, error)

	// ReadFrom reads all events from the log starting at event with specified id (excluded).
	// If id is not found behaves like Read().
	ReadFrom(id string) ([]Event, error)

	// ReadSingle gets the module metadata about the given module/version.
	// If something went wrong doing the get operation, returns a non-nil error.
	ReadSingle(module, version string) (Event, error)
}

Reader is reader of append only event log.s

func NewMultiReader

func NewMultiReader(ch storage.Checker, ll ...Eventlog) Reader

NewMultiReader creates composite reader of specified readers. Order of readers matters in a way how Events are deduplicated. Initial state: - InMemory [A, B] - as im.A, im.B R1: [C,D,E] - as r1.C... R2: [A,D,F] R3: [B, G] result [r1.C, r1.D, r1.E, r2.F, r3.G] r2.A, r2.D, r3.B - skipped due to deduplication checks

func NewMultiReaderFrom

func NewMultiReaderFrom(ch storage.Checker, l ...SequencedLog) Reader

NewMultiReaderFrom creates composite reader of specified readers. Order of readers matters in a way how Events are deduplicated. Initial state: - InMemory [A, B] - as im.A, im.B R1: [B,C,E] - as r1.C... - pointer to D R2: [A,D,F] - pointer to A R3: [B, G] - pointer to B result [r1.E, r2.D, r2.F, r3.G]

type RegisteredEventlog

type RegisteredEventlog struct {
	DeploymentID string `bson:"deployment"`
	Pointer      string `bson:"ptr"`
}

RegisteredEventlog stores the relationship between a deploymentID and the pointer to it's olympus server eventlog

type SequencedLog

type SequencedLog struct {
	Log   Eventlog
	Index string
}

SequencedLog is collection of event logs with specified starting pointers used by ReadFrom function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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