Documentation ¶
Index ¶
- type RegistryCache
- func (rc *RegistryCache) Add(serviceName string, info registry.ServiceInfo)
- func (rc *RegistryCache) Delete(serviceName string)
- func (rc *RegistryCache) Get(serviceName string) (info registry.ServiceInfo, ok bool)
- func (rc *RegistryCache) GetOrRequestService(serviceName string) (info registry.ServiceInfo, err error)
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
Click to show internal directories.
Click to hide internal directories.