expiry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opts *registeredStore)

Option is an option for registered store.

func WithExpiryHandler

func WithExpiryHandler(handler expiryHandler) Option

WithExpiryHandler sets optional expiry handler.

func WithMaxBatchSize

func WithMaxBatchSize(value int) Option

WithMaxBatchSize sets maximum number of documents to delete in a single batch.

type Service

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

Service is an expiry service that periodically polls registered stores and removes data past a specified expiration time.

func NewService

func NewService(scheduler taskManager, interval time.Duration) *Service

NewService returns a new expiry Service. interval is how frequently this service will check for (and delete as needed) expired data. Shorter intervals will remove expired data sooner at the expense of increased resource usage. Each Orb instance within a cluster should have the same interval configured in order for this service to work efficiently. coordinationStore is used for ensuring that only one Orb instance within a cluster has the duty of performing expired data cleanup (in order to avoid every instance doing the same work, which is wasteful). Every Orb instance within the cluster needs to be connected to the same database for it to work correctly. Note that when initializing Orb servers (or if the Orb server with the duty goes down) it is possible for multiple Orb instances to briefly assign themselves the duty, but only for one round. This will automatically be resolved on the next check and only one will end up with the duty from that point on. This situation is not of concern since it's safe for two instances to perform the check at the same time. instanceID is used in the coordinationStore for determining who currently has the duty of doing the expired data cleanup. It must be unique for every Orb instance within the cluster in order for this service to work efficiently. You must register each store you want this service to run on using the Register method. Once all your stores are registered, call the Start method to start the service.

func (*Service) Register

func (s *Service) Register(store storage.Store, expiryTagName, storeName string, opts ...Option)

Register adds a store to this expiry service. store is the store on which to periodically cleanup expired data. name is used to identify the purpose of this expiry service for logging purposes. expiryTagName is the tag name used to store expiry values under. The expiry values must be standard Unix timestamps.

Jump to

Keyboard shortcuts

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