cache

package
v0.0.0-...-c8fcda5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type ConfigMapCache

type ConfigMapCache struct {
	// contains filtered or unexported fields
}
var Cache *ConfigMapCache

Only create a single instance of config map cache

func NewConfigMapCache

func NewConfigMapCache() *ConfigMapCache

Create a configmap cache backed by k8s.

func NewInMemConfigMapCache

func NewInMemConfigMapCache(polls map[string]Poll, reminders map[string]Reminder) *ConfigMapCache

Create a configmap cache that is in-memory. Cache is lost if application closes.

func (*ConfigMapCache) AddPoll

func (c *ConfigMapCache) AddPoll(p *Poll) error

Add a poll configmap, this in turn triggers the informer handler which adds it to the in-mem cache.

func (*ConfigMapCache) AddReminder

func (c *ConfigMapCache) AddReminder(r *Reminder, user string) error

Add a reminder configmap, this in turn triggers the informer handler which adds it to the in-mem cache.

func (*ConfigMapCache) Delete

func (c *ConfigMapCache) Delete(name string)

Delete the configmap from the cluster which in turn triggers

the delete handler to remove it from the in-mem cache

func (*ConfigMapCache) GetPoll

func (c *ConfigMapCache) GetPoll(id, author string) *Poll

func (*ConfigMapCache) GetReminder

func (c *ConfigMapCache) GetReminder(id, author string) *Reminder

func (*ConfigMapCache) ListPolls

func (c *ConfigMapCache) ListPolls() map[string]Poll

Getter for polls in the cache

func (*ConfigMapCache) ListReminders

func (c *ConfigMapCache) ListReminders() map[string]Reminder

Getter for reminders in the cache

func (*ConfigMapCache) UpdatePoll

func (c *ConfigMapCache) UpdatePoll(p *Poll) error

type Poll

type Poll struct {
	Author  string                   `json:"author"`
	Channel string                   `json:"channel"`
	Prompt  string                   `json:"prompt"`
	Choices []string                 `json:"choices"`
	Expiry  int64                    `json:"expiry"`
	Id      string                   `json:"id"`
	Votes   map[string][]interface{} `json:"votes"`
}

func (*Poll) FromConfigMap

func (p *Poll) FromConfigMap(configMap *corev1.ConfigMap) error

func (*Poll) ToConfigMap

func (p *Poll) ToConfigMap() (*corev1.ConfigMap, error)

type Reminder

type Reminder struct {
	Author  string      `json:"author"`
	Channel string      `json:"channel"`
	Expiry  int64       `json:"expiry"`
	Message interface{} `json:"msg"`
	Id      string      `json:"id"`
}

func (*Reminder) FromConfigMap

func (r *Reminder) FromConfigMap(configMap *corev1.ConfigMap) error

func (*Reminder) ToConfigMap

func (r *Reminder) ToConfigMap() (*corev1.ConfigMap, error)

Jump to

Keyboard shortcuts

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