snapshot

package
v0.0.0-...-48a44ca Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultGroup = "default"

DefaultGroup is the default group when using the DefaultGroupIndex() function.

Variables

This section is empty.

Functions

func DefaultGroupIndex

func DefaultGroupIndex(_ *mcp.Client) string

DefaultGroupIndex provides a default GroupIndexFn function that is usable for testing and simple deployments.

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 group of clients. Cache consistently replies with the latest snapshot.

func New

func New(groupIndex GroupIndexFn) *Cache

New creates a new cache of resource snapshots.

func (*Cache) ClearSnapshot

func (c *Cache) ClearSnapshot(group string)

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

func (*Cache) ClearStatus

func (c *Cache) ClearStatus(group string)

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

func (*Cache) SetSnapshot

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

SetSnapshot updates a snapshot for a group.

func (*Cache) Status

func (c *Cache) Status(group string) *StatusInfo

Status returns informational status for a group.

func (*Cache) Watch

func (c *Cache) Watch(request *mcp.MeshConfigRequest, pushResponse server.PushResponseFunc) server.CancelWatchFunc

Watch returns a watch for an MCP request.

type GroupIndexFn

type GroupIndexFn func(client *mcp.Client) string

GroupIndexFn returns a stable group index for the given MCP client.

type InMemory

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

InMemory Snapshot implementation

func (*InMemory) Builder

func (s *InMemory) Builder() *InMemoryBuilder

Builder returns a new builder instance, based on the contents of this snapshot.

func (*InMemory) Clone

func (s *InMemory) Clone() *InMemory

Clone this snapshot.

func (*InMemory) Resources

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

Resources is an implementation of Snapshot.Resources

func (*InMemory) String

func (s *InMemory) String() string

func (*InMemory) Version

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

Version is an implementation of Snapshot.Version

type InMemoryBuilder

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

InMemoryBuilder is a builder for an InMemory snapshot.

func NewInMemoryBuilder

func NewInMemoryBuilder() *InMemoryBuilder

NewInMemoryBuilder creates and returns a new InMemoryBuilder.

func (*InMemoryBuilder) Build

func (b *InMemoryBuilder) Build() *InMemory

Build the snapshot and return.

func (*InMemoryBuilder) DeleteEntry

func (b *InMemoryBuilder) DeleteEntry(typeURL string, name string)

DeleteEntry deletes the entry with the given typeuRL, name

func (*InMemoryBuilder) Set

func (b *InMemoryBuilder) Set(typeURL 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 (*InMemoryBuilder) SetEntry

func (b *InMemoryBuilder) SetEntry(typeURL, name, version string, createTime time.Time, m proto.Message) error

SetEntry sets a single entry. Note that this is a slow operation, as update requires scanning through existing entries.

func (*InMemoryBuilder) SetVersion

func (b *InMemoryBuilder) SetVersion(typeURL string, version string)

SetVersion sets the version for the given type URL.

type Snapshot

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

Snapshot provides an immutable view of versioned envelopes.

type StatusInfo

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

StatusInfo records watch status information of a remote client.

func (*StatusInfo) LastWatchRequestTime

func (si *StatusInfo) LastWatchRequestTime() time.Time

LastWatchRequestTime returns the time the most recent watch request was received.

func (*StatusInfo) Watches

func (si *StatusInfo) Watches() int

Watches returns the number of open watches.

Jump to

Keyboard shortcuts

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