config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeighborTypeAuto    = "auto"
	NeighborTypeSimilar = "similar"
	NeighborTypeRelated = "related"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Database  DatabaseConfig  `toml:"database"`
	Master    MasterConfig    `toml:"master"`
	Server    ServerConfig    `toml:"server"`
	Recommend RecommendConfig `toml:"recommend"`
}

Config is the configuration for the engine.

func LoadConfig

func LoadConfig(path string) (*Config, *toml.MetaData, error)

LoadConfig loads configuration from toml file.

func (*Config) FillDefault

func (config *Config) FillDefault(meta toml.MetaData)

FillDefault fill default values for missing values.

func (*Config) LoadDefaultIfNil

func (config *Config) LoadDefaultIfNil() *Config

LoadDefaultIfNil loads default settings if config is nil.

type DatabaseConfig

type DatabaseConfig struct {
	DataStore            string   `toml:"data_store"`              // database for data store
	CacheStore           string   `toml:"cache_store"`             // database for cache store
	AutoInsertUser       bool     `toml:"auto_insert_user"`        // insert new users while inserting feedback
	AutoInsertItem       bool     `toml:"auto_insert_item"`        // insert new items while inserting feedback
	CacheSize            int      `toml:"cache_size"`              // cache size for recommended/popular/latest items
	PositiveFeedbackType []string `toml:"positive_feedback_types"` // positive feedback type
	ReadFeedbackType     string   `toml:"read_feedback_type"`      // feedback type for read event
	PositiveFeedbackTTL  uint     `toml:"positive_feedback_ttl"`   // time-to-live of positive feedbacks
	ItemTTL              uint     `toml:"item_ttl"`                // item-to-live of items
}

DatabaseConfig is the configuration for the database.

func (*DatabaseConfig) LoadDefaultIfNil

func (config *DatabaseConfig) LoadDefaultIfNil() *DatabaseConfig

LoadDefaultIfNil loads default settings if config is nil.

type MasterConfig

type MasterConfig struct {
	Port        int    `toml:"port"`         // master port
	Host        string `toml:"host"`         // master host
	HttpPort    int    `toml:"http_port"`    // HTTP port
	HttpHost    string `toml:"http_host"`    // HTTP host
	NumJobs     int    `toml:"n_jobs"`       // number of working jobs
	MetaTimeout int    `toml:"meta_timeout"` // cluster meta timeout (second)
}

MasterConfig is the configuration for the master.

func (*MasterConfig) LoadDefaultIfNil

func (config *MasterConfig) LoadDefaultIfNil() *MasterConfig

LoadDefaultIfNil loads default settings if config is nil.

type RecommendConfig

type RecommendConfig struct {
	PopularWindow            int      `toml:"popular_window"`
	FitPeriod                int      `toml:"fit_period"`
	SearchPeriod             int      `toml:"search_period"`
	SearchEpoch              int      `toml:"search_epoch"`
	SearchTrials             int      `toml:"search_trials"`
	RefreshRecommendPeriod   int      `toml:"refresh_recommend_period"`
	FallbackRecommend        []string `toml:"fallback_recommend"`
	ItemNeighborType         string   `toml:"item_neighbor_type"`
	UserNeighborType         string   `toml:"user_neighbor_type"`
	EnableLatestRecommend    bool     `toml:"enable_latest_recommend"`
	EnablePopularRecommend   bool     `toml:"enable_popular_recommend"`
	EnableUserBasedRecommend bool     `toml:"enable_user_based_recommend"`
	EnableItemBasedRecommend bool     `toml:"enable_item_based_recommend"`
	EnableColRecommend       bool     `toml:"enable_collaborative_recommend"`
}

RecommendConfig is the configuration of recommendation setup.

func (*RecommendConfig) LoadDefaultIfNil

func (config *RecommendConfig) LoadDefaultIfNil() *RecommendConfig

LoadDefaultIfNil loads default settings if config is nil.

type ServerConfig

type ServerConfig struct {
	APIKey   string `toml:"api_key"`   // default number of returned items
	DefaultN int    `toml:"default_n"` // secret key for RESTful APIs (SSL required)
}

ServerConfig is the configuration for the server.

func (*ServerConfig) LoadDefaultIfNil

func (config *ServerConfig) LoadDefaultIfNil() *ServerConfig

LoadDefaultIfNil loads default settings if config is nil.

Jump to

Keyboard shortcuts

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