Documentation
¶
Index ¶
- func IsOpenAIEnabled(indices []string) bool
- type Cache
- func (c *Cache) AlternateRoutes() []plugins.Route
- func (c *Cache) CreateDayStat()
- func (c *Cache) DeleteOlderRecords()
- func (c *Cache) ESMiddleware() []middleware.Middleware
- func (c *Cache) InitFunc() error
- func (f *Cache) Name() string
- func (c *Cache) RSMiddleware() []middleware.Middleware
- func (c *Cache) RollOverJob()
- func (c *Cache) Routes() []plugins.Route
- func (c *Cache) StartJobs()
- type CacheStatES
- type CachedResponse
- type RollOverStat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsOpenAIEnabled ¶
IsOpenAIEnabled will check if OpenAI is enabled by checking a few things. - If tier allows OpenAI - If cluster has OpenAI enabled - If passed index is whitelisted
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func Instance ¶
func Instance() *Cache
Instance returns the singleton instance of Cache plugin. Note: Only this function must be used (both within and outside the package) to obtain the instance Cache in order to avoid stateless instances of the plugin.
func (*Cache) AlternateRoutes ¶
Expose plugin specific routes
func (*Cache) CreateDayStat ¶
func (c *Cache) CreateDayStat()
CreateDayStat will create the stat for the day using the dayID generated.
This function should run at 12 AM everyday and will create a stat object with 0 values initialized.
func (*Cache) DeleteOlderRecords ¶
func (c *Cache) DeleteOlderRecords()
DeleteOlderRecords will delete all records that are older than 30 days.
This function will run at midnight everyday and will delete all records that are less than the created unix timestamp.
func (*Cache) ESMiddleware ¶
func (c *Cache) ESMiddleware() []middleware.Middleware
func (*Cache) InitFunc ¶
InitFunc is a part of Plugin interface that gets executed only once, and initializes the dao, i.e. elasticsearch before the plugin is operational.
func (*Cache) Name ¶
Name returns the name of the plugin: "applycache"
func (*Cache) RSMiddleware ¶
func (c *Cache) RSMiddleware() []middleware.Middleware
func (*Cache) RollOverJob ¶
func (c *Cache) RollOverJob()
RollOverJob will rollover the stats every 10 minutes.
This function will use the generatedID and use the rolled over stats every 10 minutes. This function assumes that the document is already present in the index with a proper day value set in the document so rollover will only update the stat values.
type CacheStatES ¶
type CachedResponse ¶
func ApplyCache ¶
func ApplyCache( urlPath string, rsAPIBody *querytranslate.RSQuery, requestBody []byte, startTime *time.Time, userId string, indices []string, ) (*CachedResponse, error)
type RollOverStat ¶
type RollOverStat struct {
Stat *CacheStatES
// contains filtered or unexported fields
}
func (*RollOverStat) Add ¶
func (r *RollOverStat) Add(isHit bool, performanceSave int64)
Add will add new stats to the current stat object.
The value of performanceSave will be ignored if the cache was not hit.
func (*RollOverStat) Init ¶
func (r *RollOverStat) Init() *RollOverStat
Init will initiate the RollOverStat value and return a new instance
func (*RollOverStat) RollOver ¶
func (r *RollOverStat) RollOver() *CacheStatES
Rollover will roll over the stats present currently and create an empty container to keep new data.
This function will not take care of rolling over on every n minutes or hours. That should be handled at a top level.