cache

package
v0.0.0-...-c29da01 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Cache

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

Cache subscribes to and caches Consul objects, it also responsible for mainting subscriptions to resources that it caches.

func New

func New(config Config) *Cache

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, ref api.ResourceReference) error

Delete handles deleting the config entry from consul, if the current reference of the config entry is stale then it returns an error.

func (*Cache) Deregister

func (c *Cache) Deregister(ctx context.Context, deregistration api.CatalogDeregistration) error

Deregister deregisters a service in Consul.

func (*Cache) EnsureRoleBinding

func (c *Cache) EnsureRoleBinding(authMethod, service, namespace string) error

func (*Cache) Get

Get returns a config entry from the cache that corresponds to the given resource reference.

func (*Cache) List

func (c *Cache) List(kind string) []api.ConfigEntry

List returns a list of config entries from the cache that corresponds to the given kind.

func (*Cache) Register

func (c *Cache) Register(ctx context.Context, registration api.CatalogRegistration) error

Register registers a service in Consul.

func (*Cache) Run

func (c *Cache) Run(ctx context.Context)

Run starts the cache watch cycle, on the first call it will fill the cache with existing resources.

func (*Cache) Subscribe

func (c *Cache) Subscribe(ctx context.Context, kind string, translator TranslatorFn) *Subscription

Subscribe handles adding a new subscription for resources of a given kind.

func (*Cache) WaitSynced

func (c *Cache) WaitSynced(ctx context.Context)

WaitSynced is used to coordinate with the caller when the cache is initially filled.

func (*Cache) Write

func (c *Cache) Write(ctx context.Context, entry api.ConfigEntry) error

Write handles writing the config entry back to Consul, if the current reference of the config entry is stale then it returns an error.

type Config

type Config struct {
	ConsulClientConfig      *consul.Config
	ConsulServerConnMgr     consul.ServerConnectionManager
	NamespacesEnabled       bool
	Datacenter              string
	CrossNamespaceACLPolicy string
	Logger                  logr.Logger
}

type GatewayCache

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

func NewGatewayCache

func NewGatewayCache(ctx context.Context, config Config) *GatewayCache

func (*GatewayCache) EnsureSubscribed

func (r *GatewayCache) EnsureSubscribed(ref api.ResourceReference, resource types.NamespacedName)

func (*GatewayCache) FetchServicesFor

func (r *GatewayCache) FetchServicesFor(ctx context.Context, ref api.ResourceReference) ([]api.CatalogService, error)

func (*GatewayCache) RemoveSubscription

func (r *GatewayCache) RemoveSubscription(ref api.ResourceReference)

func (*GatewayCache) ServicesFor

func (r *GatewayCache) ServicesFor(ref api.ResourceReference) []api.CatalogService

type Subscription

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

Subscription represents a watcher for events on a specific kind.

func (*Subscription) Cancel

func (s *Subscription) Cancel()

func (*Subscription) Events

func (s *Subscription) Events() chan event.GenericEvent

type TranslatorFn

type TranslatorFn func(api.ConfigEntry) []types.NamespacedName

Jump to

Keyboard shortcuts

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