Documentation
¶
Index ¶
- Constants
- Variables
- type List
- type NavigationCache
- type Subtopic
- type Subtopics
- func (t *Subtopics) AppendSubtopicID(id string, subtopic Subtopic)
- func (t *Subtopics) CheckTopicIDExists(key string) bool
- func (t *Subtopics) Get(key string) (Subtopic, bool)
- func (t *Subtopics) GetBySlugAndParentSlug(slug, parentSlug string) (Subtopic, bool)
- func (t *Subtopics) GetSubtopics() (subtopics []Subtopic)
- func (t *Subtopics) GetSubtopicsIDsQuery() string
- type Topic
- type TopicCache
- func (dc *TopicCache) AddUpdateFunc(title string, updateFunc func() *Topic)
- func (dc *TopicCache) GetCensusData(ctx context.Context) (*Topic, error)
- func (dc *TopicCache) GetData(ctx context.Context, key string) (*Topic, error)
- func (dc *TopicCache) GetDataTopicCacheKey() string
- func (dc *TopicCache) GetTopic(ctx context.Context, slug, parentSlug string) (*Subtopic, error)
- func (dc *TopicCache) GetTopicFromSubtopic(subtopic *Subtopic) *Topic
Constants ¶
const ( // DataTopicCacheKey is used to cache the topics data DataTopicCacheKey = "root-topic-cache" )NavigationCacheKey = "navigation-cache"
Variables ¶
var CensusTopicID string
CensusTopicID is the id of the Census topic stored in mongodb which is accessible by using dp-topic-api
Functions ¶
This section is empty.
Types ¶
type List ¶ added in v0.33.0
type List struct { CensusTopic *TopicCache DataTopic *TopicCache }
CacheList is a list of caches for the dp-frontend-search-controller
type NavigationCache ¶ added in v0.33.0
type NavigationCache struct {
}NavigationCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching navigation data
func NewNavigationCache ¶ added in v0.33.0
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 ¶ added in v0.33.0
func (nc *NavigationCache) AddUpdateFunc(key string, updateFunc func() *models.Navigation)
AddUpdateFunc adds an update function to the cache
func (*NavigationCache) GetCachingKeyForNavigationLanguage ¶ added in v0.33.0
func (nc *NavigationCache) GetCachingKeyForNavigationLanguage(lang string) string
func (*NavigationCache) GetNavigationData ¶ added in v0.33.0
func (nc *NavigationCache) GetNavigationData(ctx context.Context, lang string) (*models.Navigation, error)
type Subtopic ¶ added in v0.34.0
type Subtopic struct { ID string LocaliseKeyName string Slug string ReleaseDate *time.Time ParentID string ParentSlug string }
Subtopic represents the data which is cached for a subtopic to be used by the dp-frontend-search-controller
func GetEmptySubTopic ¶ added in v0.61.0
func GetEmptySubTopic() *Subtopic
GetEmptySubTopic returns an empty topic cache in the event when updating the cache of the topic fails
type Subtopics ¶ added in v0.34.0
type Subtopics struct {
// contains filtered or unexported fields
}
Subtopics 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 ¶
func NewSubTopicsMap() *Subtopics
GetNewSubTopicsMap creates a new subtopics id map to store subtopic ids with addition to mutex locking
func (*Subtopics) AppendSubtopicID ¶ added in v0.34.0
AppendSubtopicID appends the subtopic id to the map stored in SubtopicsIDs with consideration to mutex locking
func (*Subtopics) CheckTopicIDExists ¶ added in v0.34.0
CheckTopicIDExists returns subtopic for given key (id)
func (*Subtopics) GetBySlugAndParentSlug ¶ added in v0.63.0
GetBySlugAndParentSlug returns a subtopic that matches the given topic slug and parentSlug
func (*Subtopics) GetSubtopics ¶ added in v0.34.0
GetSubtopics returns an array of subtopics
func (*Subtopics) GetSubtopicsIDsQuery ¶ added in v0.34.0
GetSubtopicsIDsQuery gets the subtopics ID query for a topic
type Topic ¶
type Topic struct { ID string LocaliseKeyName string Slug string ReleaseDate *time.Time // 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]Subtopics which contains the topic id and a list of it's subtopics List *Subtopics }
Topic represents the data which is cached for a topic to be used by the dp-frontend-search-controller
func GetEmptyCensusTopic ¶
func GetEmptyCensusTopic() *Topic
GetEmptyCensusTopic returns an empty census topic cache in the event when updating the cache of the census topic fails
func GetEmptyTopic ¶ added in v0.57.0
func GetEmptyTopic() *Topic
GetEmptyTopic returns an empty topic cache in the event when updating the cache of the topic fails
func GetMockCensusTopic ¶
func GetMockCensusTopic() *Topic
GetMockCensusTopic returns a mocked Cenus topic which contains all the information for the mock census topic
func GetMockRootTopic ¶ added in v0.61.0
GetMockRootTopic returns the mocked root topic
type TopicCache ¶
TopicCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching topics
func NewTopicCache ¶
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 ¶
func (dc *TopicCache) AddUpdateFunc(title string, updateFunc func() *Topic)
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 ¶
func (dc *TopicCache) GetCensusData(ctx context.Context) (*Topic, error)
func (*TopicCache) GetDataTopicCacheKey ¶ added in v0.61.0
func (dc *TopicCache) GetDataTopicCacheKey() string
GetDataTopicCacheKey gets the constant value set for the root topic cache key
func (*TopicCache) GetTopicFromSubtopic ¶ added in v0.61.0
func (dc *TopicCache) GetTopicFromSubtopic(subtopic *Subtopic) *Topic
GetTopicFromSubtopic returns an empty topic cache in the event when updating the cache of the topic fails