cache - ActiveState ActiveGo 1.8
...

Package cache

import "github.com/go-kit/kit/sd/cache"
Overview
Index

Overview ▾

type Cache

Cache collects the most recent set of endpoints from a service discovery system via a subscriber, and makes them available to consumers. Cache is meant to be embedded inside of a concrete subscriber, and can serve Service invocations directly.

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

func New

func New(factory sd.Factory, logger log.Logger) *Cache

New returns a new, empty endpoint cache.

func (*Cache) Endpoints

func (c *Cache) Endpoints() []endpoint.Endpoint

Endpoints yields the current set of (presumably identical) endpoints, ordered lexicographically by the corresponding instance string.

func (*Cache) Update

func (c *Cache) Update(instances []string)

Update should be invoked by clients with a complete set of current instance strings whenever that set changes. The cache manufactures new endpoints via the factory, closes old endpoints when they disappear, and persists existing endpoints if they survive through an update.