rcache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RegistryCache

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

func NewRegistryCache

func NewRegistryCache(ctx context.Context, host host.Host,
	routingDiscovery *discovery.RoutingDiscovery, ttl int) *RegistryCache

Create new RegistryCache ctx, host, routingDiscovery: used when you call GetOrRequestService() to contact registry-service ttl: time-to-live in seconds

func (*RegistryCache) Add

func (rc *RegistryCache) Add(serviceName string, info registry.ServiceInfo)

Maps serviceName to info in cache Sets expiry by checking current time and adding TTL

func (*RegistryCache) Delete

func (rc *RegistryCache) Delete(serviceName string)

Delete entry from cache

func (*RegistryCache) Get

func (rc *RegistryCache) Get(serviceName string) (info registry.ServiceInfo, ok bool)

If serviceName entry doesn't exist in cache or is expired, ok is false Otherwise, returns mapped ServiceInfo and ok is true

func (*RegistryCache) GetOrRequestService

func (rc *RegistryCache) GetOrRequestService(serviceName string) (info registry.ServiceInfo, err error)

Try to get service info from cache If not in cache or expired, request it from registry-service and add it to cache

Jump to

Keyboard shortcuts

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