snapshot

package
v0.0.0-...-5c99f88 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 11 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 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 *source.Request, pushResponse source.PushResponseFunc) source.CancelWatchFunc

Watch returns a watch for an MCP request.

type GroupIndexFn

type GroupIndexFn func(collection string, node *mcp.SinkNode) string

GroupIndexFn returns a stable group index for the given MCP collection and node. This is how an MCP server partitions snapshots to different clients. The index function is an implementation detail of the MCP server and Istio does not depend on any particular mapping.

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(collection string) []*mcp.Resource

Resources is an implementation of Snapshot.Resources

func (*InMemory) String

func (s *InMemory) String() string

func (*InMemory) Version

func (s *InMemory) Version(collection 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(collection string, name string)

DeleteEntry deletes the named entry within the given collection.

func (*InMemoryBuilder) Set

func (b *InMemoryBuilder) Set(collection, version string, resources []*mcp.Resource)

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

func (*InMemoryBuilder) SetEntry

func (b *InMemoryBuilder) SetEntry(collection, name, version string, createTime time.Time, labels,
	annotations map[string]string, 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(collection string, version string)

SetVersion sets the version for the given collection

type Snapshot

type Snapshot interface {
	Resources(collection string) []*mcp.Resource
	Version(collection string) string
}

Snapshot provides an immutable view of versioned resources.

type StatusInfo

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

StatusInfo records watch status information of a remote node.

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