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.
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 ¶
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 Oak 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 Oak 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 Oak instance within the cluster needs to be connected to the same database for it to work correctly. Note that when initializing Oak servers (or if the Oak server with the duty goes down) it is possible for multiple Oak 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 Oak 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 ¶
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.