snapshot

package
v0.0.0-...-d8a8f93 Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a snapshot-based cache that maintains a single versioned snapshot of responses per client. Cache consistently replies with the latest snapshot.

func New

func New() *Cache

New creates a new cache of resource snapshots.

func (*Cache) ClearSnapshot

func (c *Cache) ClearSnapshot(node string)

ClearSnapshot clears snapshot for a client. This does not cancel any open watches already created (see ClearStatus).

func (*Cache) ClearStatus

func (c *Cache) ClearStatus(node string)

ClearStatus clears status for a client. This has the effect of canceling any open watches opened against this client info.

func (*Cache) SetSnapshot

func (c *Cache) SetSnapshot(node string, snapshot Snapshot)

SetSnapshot updates a snapshot for a client.

func (*Cache) Watch

func (c *Cache) Watch(request *mcp.MeshConfigRequest, responseC chan<- *server.WatchResponse) (*server.WatchResponse, server.CancelWatchFunc)

Watch returns a watch for an MCP request.

type InMemory

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

InMemory Snapshot implementation

func NewInMemory

func NewInMemory() *InMemory

NewInMemory creates a new InMemory snapshot implementation

func (*InMemory) Freeze

func (s *InMemory) Freeze()

Freeze the snapshot, so that it won't get mutated anymore.

func (*InMemory) Resources

func (s *InMemory) Resources(typ string) []*mcp.Envelope

Resources is an implementation of Snapshot.Resources

func (*InMemory) Set

func (s *InMemory) Set(typ string, version string, resources []*mcp.Envelope)

Set the values for a given type. If Set is called after a call to Freeze, then this method panics.

func (*InMemory) String

func (s *InMemory) String() string

func (*InMemory) Version

func (s *InMemory) Version(typ string) string

Version is an implementation of Snapshot.Version

type Snapshot

type Snapshot interface {
	Resources(typ string) []*mcp.Envelope
	Version(typ string) string
}

Snapshot provides an immutable view of versioned envelopes.

Jump to

Keyboard shortcuts

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