Documentation
¶
Index ¶
- Constants
- Variables
- type FeedbackCache
- type HealthStatus
- type ItemCache
- type ScheduleState
- type Worker
- func (w *Worker) Pull()
- func (w *Worker) Recommend(users []data.User)
- func (w *Worker) ScheduleAPIHandler(writer http.ResponseWriter, request *http.Request)
- func (w *Worker) Serve()
- func (w *Worker) ServeHTTP()
- func (w *Worker) SetOneMode(settings *config.Settings)
- func (w *Worker) Sync()
- func (w *Worker) WorkerName() (string, error)
Constants ¶
const ( LabelStep = "step" LabelData = "data" )
Variables ¶
var ( UpdateUserRecommendTotal = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: "gorse", Subsystem: "worker", Name: "update_user_recommend_total", }) OfflineRecommendStepSecondsVec = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "gorse", Subsystem: "worker", Name: "offline_recommend_step_seconds", }, []string{LabelStep}) OfflineRecommendTotalSeconds = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: "gorse", Subsystem: "worker", Name: "offline_recommend_total_seconds", }) CollaborativeFilteringIndexRecall = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: "gorse", Subsystem: "worker", Name: "collaborative_filtering_index_recall", }) MemoryInuseBytesVec = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "gorse", Subsystem: "worker", Name: "memory_inuse_bytes", }, []string{LabelData}) )
Functions ¶
This section is empty.
Types ¶
type FeedbackCache ¶
type FeedbackCache struct {
*config.Config
Client data.Database
Types []expression.FeedbackTypeExpression
Cache cmap.ConcurrentMap
}
FeedbackCache is the cache for user feedbacks.
func NewFeedbackCache ¶
func NewFeedbackCache(worker *Worker, feedbackTypes ...expression.FeedbackTypeExpression) *FeedbackCache
NewFeedbackCache creates a new FeedbackCache.
func (*FeedbackCache) GetUserFeedback ¶
GetUserFeedback gets user feedback from cache or database.
type HealthStatus ¶
type ItemCache ¶
ItemCache is alias of map[string]data.Item.
func NewItemCache ¶
func NewItemCache() *ItemCache
func (*ItemCache) GetCategory ¶
func (*ItemCache) IsAvailable ¶
IsAvailable means the item exists in database and is not hidden.
type ScheduleState ¶
type Worker ¶
Worker manages states of a worker node.
func NewWorker ¶
func NewWorker( masterHost string, masterPort int, httpHost string, httpPort int, jobs int, cacheFile string, tlsConfig *util.TLSConfig, ) *Worker
NewWorker creates a new worker node.
func (*Worker) Recommend ¶
Recommend items to users. The workflow of recommendation is: 1. Skip inactive users. 2. Load historical items. 3. Load positive items if KNN used. 4. Generate recommendation. 5. Save result. 6. Insert cold-start items into results. 7. Rank items in results by click-through-rate. 8. Refresh cache.
func (*Worker) ScheduleAPIHandler ¶
func (w *Worker) ScheduleAPIHandler(writer http.ResponseWriter, request *http.Request)
func (*Worker) ServeHTTP ¶
func (w *Worker) ServeHTTP()
ServeHTTP serves Prometheus metrics and API.