Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSRecord ¶
type DNSRecord struct { // LastUpdate is the last update time as a Unix timestamp. LastUpdate int64 // Ports contains a list of service ports to monitor Ports []string }
DNSRecord represents a DNS record with a last update time to verify if the hostname is still active or expired.
type GarbageCollector ¶
type GarbageCollector struct { MemorystoreClient[Status] // contains filtered or unexported fields }
GarbageCollector is a tracker that implements automatic garbage collection of stale entities - i.e. entities whose registration has not been updated for longer than the configured TTL.
When the GarbageCollector is created, it spawns a goroutine that periodically reads all entities in Memorystore and checks if their registration has expired. If an entity has expired, it is deleted from both Cloud DNS and Memorystore.
func NewGarbageCollector ¶
func NewGarbageCollector(dns dnsiface.Service, project string, msClient MemorystoreClient[Status], ttl, interval time.Duration) *GarbageCollector
NewGarbageCollector returns a new garbage-collected tracker for DNS entries and spawns a goroutine to periodically check and delete expired entities.
func (*GarbageCollector) Delete ¶
func (gc *GarbageCollector) Delete(hostname string) error
func (*GarbageCollector) Stop ¶
func (gc *GarbageCollector) Stop()
type MemorystoreClient ¶
type MemorystoreClient[V any] interface { Put(key string, field string, value redis.Scanner, opts *memorystore.PutOptions) error GetAll() (map[string]V, error) Del(key string) error }
MemorystoreClient is a client for reading and writing data in Memorystore. The interface takes in a type argument which specifies the types of values that are stored and can be retrieved.