Documentation ¶
Index ¶
- Constants
- func DefaultGroupIndex(_ *mcp.SinkNode) string
- type Cache
- func (c *Cache) ClearSnapshot(group string)
- func (c *Cache) ClearStatus(group string)
- func (c *Cache) SetSnapshot(group string, snapshot Snapshot)
- func (c *Cache) Status(group string) *StatusInfo
- func (c *Cache) Watch(request *source.Request, pushResponse source.PushResponseFunc) source.CancelWatchFunc
- type GroupIndexFn
- type InMemory
- type InMemoryBuilder
- func (b *InMemoryBuilder) Build() *InMemory
- func (b *InMemoryBuilder) DeleteEntry(collection string, name string)
- func (b *InMemoryBuilder) Set(collection, version string, resources []*mcp.Resource)
- func (b *InMemoryBuilder) SetEntry(collection, name, version string, createTime time.Time, ...) error
- func (b *InMemoryBuilder) SetVersion(collection string, version string)
- type Snapshot
- type StatusInfo
Constants ¶
const DefaultGroup = "default"
DefaultGroup is the default group when using the DefaultGroupIndex() function.
Variables ¶
This section is empty.
Functions ¶
func DefaultGroupIndex ¶
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 (*Cache) ClearSnapshot ¶
ClearSnapshot clears snapshot for a group. This does not cancel any open watches already created (see ClearStatus).
func (*Cache) ClearStatus ¶
ClearStatus clears status for a group. This has the effect of canceling any open watches opened against this group info.
func (*Cache) SetSnapshot ¶
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 ¶
GroupIndexFn returns a stable group index for the given MCP node.
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.
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.