config

package
v0.0.0-...-70f0bbd Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 32 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 CollaborativeConfig

type CollaborativeConfig struct {
	ModelFitPeriod        time.Duration `mapstructure:"model_fit_period" validate:"gt=0"`
	ModelSearchPeriod     time.Duration `mapstructure:"model_search_period" validate:"gt=0"`
	ModelSearchEpoch      int           `mapstructure:"model_search_epoch" validate:"gt=0"`
	ModelSearchTrials     int           `mapstructure:"model_search_trials" validate:"gt=0"`
	EnableModelSizeSearch bool          `mapstructure:"enable_model_size_search"`
	EnableIndex           bool          `mapstructure:"enable_index"`
	IndexRecall           float32       `mapstructure:"index_recall" validate:"gt=0"`
	IndexFitEpoch         int           `mapstructure:"index_fit_epoch" validate:"gt=0"`
}

type Config

type Config struct {
	Database     DatabaseConfig     `mapstructure:"database"`
	Master       MasterConfig       `mapstructure:"master"`
	Server       ServerConfig       `mapstructure:"server"`
	Recommend    RecommendConfig    `mapstructure:"recommend"`
	Tracing      TracingConfig      `mapstructure:"tracing"`
	Experimental ExperimentalConfig `mapstructure:"experimental"`
}

Config is the configuration for the engine.

func GetDefaultConfig

func GetDefaultConfig() *Config

func LoadConfig

func LoadConfig(path string, oneModel bool) (*Config, error)

LoadConfig loads configuration from toml file.

func (*Config) ItemNeighborDigest

func (config *Config) ItemNeighborDigest() string

func (*Config) Now

func (config *Config) Now() *time.Time

func (*Config) OfflineRecommendDigest

func (config *Config) OfflineRecommendDigest(option ...DigestOption) string

func (*Config) UserNeighborDigest

func (config *Config) UserNeighborDigest() string

func (*Config) Validate

func (config *Config) Validate(oneModel bool) error

type DataSourceConfig

type DataSourceConfig struct {
	PositiveFeedbackTypes []string `mapstructure:"positive_feedback_types"`                // positive feedback type
	ReadFeedbackTypes     []string `mapstructure:"read_feedback_types"`                    // feedback type for read event
	PositiveFeedbackTTL   uint     `mapstructure:"positive_feedback_ttl" validate:"gte=0"` // time-to-live of positive feedbacks
	ItemTTL               uint     `mapstructure:"item_ttl" validate:"gte=0"`              // item-to-live of items
}

type DatabaseConfig

type DatabaseConfig struct {
	DataStore        string `mapstructure:"data_store" validate:"required,data_store"`   // database for data store
	CacheStore       string `mapstructure:"cache_store" validate:"required,cache_store"` // database for cache store
	TablePrefix      string `mapstructure:"table_prefix"`
	DataTablePrefix  string `mapstructure:"data_table_prefix"`
	CacheTablePrefix string `mapstructure:"cache_table_prefix"`
}

DatabaseConfig is the configuration for the database.

type DigestOption

type DigestOption func(option *digestOptions)

func WithCollaborative

func WithCollaborative(v bool) DigestOption

func WithItemNeighborDigest

func WithItemNeighborDigest(digest string) DigestOption

func WithRanking

func WithRanking(v bool) DigestOption

func WithUserNeighborDigest

func WithUserNeighborDigest(digest string) DigestOption

type ExperimentalConfig

type ExperimentalConfig struct {
	EnableDeepLearning    bool `mapstructure:"enable_deep_learning"`
	DeepLearningBatchSize int  `mapstructure:"deep_learning_batch_size"`
}

type MasterConfig

type MasterConfig struct {
	Port                int           `mapstructure:"port" validate:"gte=0"`        // master port
	Host                string        `mapstructure:"host"`                         // master host
	HttpPort            int           `mapstructure:"http_port" validate:"gte=0"`   // HTTP port
	HttpHost            string        `mapstructure:"http_host"`                    // HTTP host
	HttpCorsDomains     []string      `mapstructure:"http_cors_domains"`            // add allowed cors domains
	HttpCorsMethods     []string      `mapstructure:"http_cors_methods"`            // add allowed cors methods
	NumJobs             int           `mapstructure:"n_jobs" validate:"gt=0"`       // number of working jobs
	MetaTimeout         time.Duration `mapstructure:"meta_timeout" validate:"gt=0"` // cluster meta timeout (second)
	DashboardUserName   string        `mapstructure:"dashboard_user_name"`          // dashboard user name
	DashboardPassword   string        `mapstructure:"dashboard_password"`           // dashboard password
	DashboardAuthServer string        `mapstructure:"dashboard_auth_server"`        // dashboard auth server
	DashboardRedacted   bool          `mapstructure:"dashboard_redacted"`
	AdminAPIKey         string        `mapstructure:"admin_api_key"`
}

MasterConfig is the configuration for the master.

type NeighborsConfig

type NeighborsConfig struct {
	NeighborType  string  `mapstructure:"neighbor_type" validate:"oneof=auto similar related ''"`
	EnableIndex   bool    `mapstructure:"enable_index"`
	IndexRecall   float32 `mapstructure:"index_recall" validate:"gt=0"`
	IndexFitEpoch int     `mapstructure:"index_fit_epoch" validate:"gt=0"`
}

type OfflineConfig

type OfflineConfig struct {
	CheckRecommendPeriod         time.Duration      `mapstructure:"check_recommend_period" validate:"gt=0"`
	RefreshRecommendPeriod       time.Duration      `mapstructure:"refresh_recommend_period" validate:"gt=0"`
	ExploreRecommend             map[string]float64 `mapstructure:"explore_recommend"`
	EnableLatestRecommend        bool               `mapstructure:"enable_latest_recommend"`
	EnablePopularRecommend       bool               `mapstructure:"enable_popular_recommend"`
	EnableUserBasedRecommend     bool               `mapstructure:"enable_user_based_recommend"`
	EnableItemBasedRecommend     bool               `mapstructure:"enable_item_based_recommend"`
	EnableColRecommend           bool               `mapstructure:"enable_collaborative_recommend"`
	EnableClickThroughPrediction bool               `mapstructure:"enable_click_through_prediction"`
	// contains filtered or unexported fields
}

func (*OfflineConfig) GetExploreRecommend

func (config *OfflineConfig) GetExploreRecommend(key string) (value float64, exist bool)

func (*OfflineConfig) Lock

func (config *OfflineConfig) Lock()

func (*OfflineConfig) UnLock

func (config *OfflineConfig) UnLock()

type OnlineConfig

type OnlineConfig struct {
	FallbackRecommend            []string `mapstructure:"fallback_recommend"`
	NumFeedbackFallbackItemBased int      `mapstructure:"num_feedback_fallback_item_based" validate:"gt=0"`
}

type PopularConfig

type PopularConfig struct {
	PopularWindow time.Duration `mapstructure:"popular_window" validate:"gte=0"`
}

type RecommendConfig

type RecommendConfig struct {
	CacheSize     int                 `mapstructure:"cache_size" validate:"gt=0"`
	CacheExpire   time.Duration       `mapstructure:"cache_expire" validate:"gt=0"`
	ActiveUserTTL int                 `mapstructure:"active_user_ttl" validate:"gte=0"`
	DataSource    DataSourceConfig    `mapstructure:"data_source"`
	Popular       PopularConfig       `mapstructure:"popular"`
	UserNeighbors NeighborsConfig     `mapstructure:"user_neighbors"`
	ItemNeighbors NeighborsConfig     `mapstructure:"item_neighbors"`
	Collaborative CollaborativeConfig `mapstructure:"collaborative"`
	Replacement   ReplacementConfig   `mapstructure:"replacement"`
	Offline       OfflineConfig       `mapstructure:"offline"`
	Online        OnlineConfig        `mapstructure:"online"`
}

RecommendConfig is the configuration of recommendation setup.

type ReplacementConfig

type ReplacementConfig struct {
	EnableReplacement        bool    `mapstructure:"enable_replacement"`
	PositiveReplacementDecay float64 `mapstructure:"positive_replacement_decay" validate:"gt=0"`
	ReadReplacementDecay     float64 `mapstructure:"read_replacement_decay" validate:"gt=0"`
}

type ServerConfig

type ServerConfig struct {
	APIKey         string        `mapstructure:"api_key"`                      // default number of returned items
	DefaultN       int           `mapstructure:"default_n" validate:"gt=0"`    // secret key for RESTful APIs (SSL required)
	ClockError     time.Duration `mapstructure:"clock_error" validate:"gte=0"` // clock error in the cluster in seconds
	AutoInsertUser bool          `mapstructure:"auto_insert_user"`             // insert new users while inserting feedback
	AutoInsertItem bool          `mapstructure:"auto_insert_item"`             // insert new items while inserting feedback
	CacheExpire    time.Duration `mapstructure:"cache_expire" validate:"gt=0"` // server-side cache expire time
}

ServerConfig is the configuration for the server.

type Settings

type Settings struct {
	Config *Config

	// database clients
	CacheClient cache.Database
	DataClient  data.Database

	// recommendation models
	RankingModel        ranking.MatrixFactorization
	RankingModelVersion int64
	ClickModel          click.FactorizationMachine
	ClickModelVersion   int64
}

func NewSettings

func NewSettings() *Settings

type TracingConfig

type TracingConfig struct {
	EnableTracing     bool    `mapstructure:"enable_tracing"`
	Exporter          string  `mapstructure:"exporter" validate:"oneof=jaeger zipkin otlp otlphttp"`
	CollectorEndpoint string  `mapstructure:"collector_endpoint"`
	Sampler           string  `mapstructure:"sampler"`
	Ratio             float64 `mapstructure:"ratio"`
}

func (*TracingConfig) Equal

func (config *TracingConfig) Equal(other TracingConfig) bool

func (*TracingConfig) NewTracerProvider

func (config *TracingConfig) NewTracerProvider() (trace.TracerProvider, error)

Jump to

Keyboard shortcuts

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