Documentation
¶
Index ¶
Constants ¶
const ( // HomepageCacheKey is used to cache the rendered homepage HomepageCacheKey = "homepage-cache" NavigationCacheKey = "navigation-cache" )
Variables ¶
var ( // CensusTopicID is the id of the Census topic stored in mongodb which is accessible by using dp-topic-api CensusTopicID string // List of possible errors ErrEmptyTopicCache = errors.New("topicCacheData is nil") ErrMissingCacheID = errors.New("missing id value, set to empty string") ErrTopicCacheWrongType = errors.New("topicCacheInterface is not type *Topic") )
Functions ¶
func ErrTopicCacheKeyMissing ¶ added in v1.29.0
ErrTopicCacheKeyMissing to generate error message
Types ¶
type HomepageCache ¶
HomepageCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching homepage data
func NewHomepageCache ¶
NewHomepageCache create a homepage cache object to be used in the service which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of the service
func (*HomepageCache) AddUpdateFunc ¶
func (hc *HomepageCache) AddUpdateFunc(key string, updateFunc func() (*model.HomepageData, error))
AddUpdateFunc adds an update function to the homepage cache
type List ¶ added in v1.29.0
type List struct { CensusTopic *TopicCache }
CacheList is a list of caches for the dp-frontend-search-controller
type NavigationCache ¶
type NavigationCache struct {
}NavigationCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching navigation data
func NewNavigationCache ¶
func NewNavigationCache(ctx context.Context, updateInterval *time.Duration) (*NavigationCache, error)
NewNavigationCache create a navigation cache object to be used in the service which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of the service
func (*NavigationCache) AddUpdateFunc ¶
func (nc *NavigationCache) AddUpdateFunc(key string, updateFunc func() *models.Navigation)
AddUpdateFunc adds an update function to the homepage cache
type SubtopicsIDs ¶ added in v1.29.0
type SubtopicsIDs struct {
// contains filtered or unexported fields
}
SubtopicsIDs contains a list of subtopics in map form with addition to mutex locking The subtopicsMap is used to keep a record of subtopics to be later used to generate the subtopics id `query` for a topic and to check if the subtopic id given by a user exists
func NewSubTopicsMap ¶ added in v1.29.0
func NewSubTopicsMap() *SubtopicsIDs
NewSubTopicsMap creates a new subtopics id map to store subtopic ids with addition to mutex locking
func (*SubtopicsIDs) AppendSubtopicItems ¶ added in v1.29.0
func (t *SubtopicsIDs) AppendSubtopicItems(topic *models.Topic)
AppendSubtopicID appends the subtopic id to the map stored in SubtopicsIDs with consideration to mutex locking
func (*SubtopicsIDs) Get ¶ added in v1.29.0
func (t *SubtopicsIDs) Get(key string) bool
Get returns a bool value for the given key (id) to inform that the subtopic id exists
func (*SubtopicsIDs) GetSubtopicItems ¶ added in v1.29.0
func (t *SubtopicsIDs) GetSubtopicItems() map[string]*models.Topic
GetSubtopicItems returns a list of subtopics for given topic
func (*SubtopicsIDs) GetSubtopicsIDsQuery ¶ added in v1.29.0
func (t *SubtopicsIDs) GetSubtopicsIDsQuery() string
GetSubtopicsIDsQuery gets the subtopics ID query for a topic
type Topic ¶ added in v1.29.0
type Topic struct { ID string LocaliseKeyName string // Query is a comma separated string of topic id and its subtopic ids which will be used by the controller to create the query Query string // List is a map[string]bool which contains the topic id and its subtopic ids which will be used to check if the topic id given by the user exists List *SubtopicsIDs }
Topic represents the data which is cached for a topic to be used by the dp-frontend-search-controller
func GetEmptyCensusTopic ¶ added in v1.29.0
func GetEmptyCensusTopic() *Topic
GetEmptyCensusTopic returns an empty census topic cache in the event when updating the cache of the census topic fails
func GetMockCensusTopic ¶ added in v1.29.0
func GetMockCensusTopic() *Topic
GetMockCensusTopic returns a mocked Cenus topic which contains all the information for the mock census topic
type TopicCache ¶ added in v1.29.0
TopicCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching topics
func NewTopicCache ¶ added in v1.29.0
NewTopicCache create a topic cache object to be used in the service which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of the service
func (*TopicCache) AddUpdateFunc ¶ added in v1.29.0
AddUpdateFunc adds an update function to the topic cache for a topic with the `title` passed to the function This update function will then be triggered once or at every fixed interval as per the prior setup of the TopicCache
func (*TopicCache) GetCensusData ¶ added in v1.29.0
func (dc *TopicCache) GetCensusData(ctx context.Context) (*Topic, error)