Documentation
¶
Index ¶
- type AuthConfig
- type Client
- type ClientConfig
- type ClientOption
- type DefaultClientFactory
- type Feature
- type FeatureMapping
- type FeatureServiceAdapter
- func (a *FeatureServiceAdapter) BatchGetItemFeatures(ctx context.Context, itemIDs []string) (map[string]map[string]float64, error)
- func (a *FeatureServiceAdapter) BatchGetRealtimeFeatures(ctx context.Context, pairs []core.FeatureUserItemPair) (map[core.FeatureUserItemPair]map[string]float64, error)
- func (a *FeatureServiceAdapter) BatchGetUserFeatures(ctx context.Context, userIDs []string) (map[string]map[string]float64, error)
- func (a *FeatureServiceAdapter) Close(ctx context.Context) error
- func (a *FeatureServiceAdapter) GetItemFeatures(ctx context.Context, itemID string) (map[string]float64, error)
- func (a *FeatureServiceAdapter) GetRealtimeFeatures(ctx context.Context, userID, itemID string) (map[string]float64, error)
- func (a *FeatureServiceAdapter) GetUserFeatures(ctx context.Context, userID string) (map[string]float64, error)
- func (a *FeatureServiceAdapter) Name() string
- type FeatureServiceInfo
- type FeatureVector
- type GetHistoricalFeaturesRequest
- type GetHistoricalFeaturesResponse
- type GetOnlineFeaturesRequest
- type GetOnlineFeaturesResponse
- type HTTPClient
- func (c *HTTPClient) Close() error
- func (c *HTTPClient) GetFeatureService(ctx context.Context) (*FeatureServiceInfo, error)
- func (c *HTTPClient) GetHistoricalFeatures(ctx context.Context, req *GetHistoricalFeaturesRequest) (*GetHistoricalFeaturesResponse, error)
- func (c *HTTPClient) GetOnlineFeatures(ctx context.Context, req *GetOnlineFeaturesRequest) (*GetOnlineFeaturesResponse, error)
- func (c *HTTPClient) ListFeatures(ctx context.Context) ([]Feature, error)
- func (c *HTTPClient) Materialize(ctx context.Context, req *MaterializeRequest) error
- type MaterializeRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
// Type 认证类型:basic, bearer, api_key, static
Type string
// Username 用户名(basic auth)
Username string
// Password 密码(basic auth)
Password string
// Token Token(bearer auth 或 static auth)
Token string
// APIKey API Key(api_key auth)
APIKey string
}
AuthConfig 认证配置
type Client ¶
type Client interface {
// GetOnlineFeatures 获取在线特征(用于实时预测)
GetOnlineFeatures(ctx context.Context, req *GetOnlineFeaturesRequest) (*GetOnlineFeaturesResponse, error)
// GetHistoricalFeatures 获取历史特征(用于训练数据)
GetHistoricalFeatures(ctx context.Context, req *GetHistoricalFeaturesRequest) (*GetHistoricalFeaturesResponse, error)
// Materialize 将特征物化到在线存储
Materialize(ctx context.Context, req *MaterializeRequest) error
// ListFeatures 列出所有可用的特征
ListFeatures(ctx context.Context) ([]Feature, error)
// GetFeatureService 获取特征服务信息
GetFeatureService(ctx context.Context) (*FeatureServiceInfo, error)
// Close 关闭客户端连接
Close() error
}
Client 是 Feast Feature Store 的客户端接口。
注意:此接口位于扩展包中,是基础设施层接口。 领域层应使用 feature.FeatureService 接口。
参考:https://github.com/feast-dev/feast
func NewClient ¶
func NewClient(endpoint, project string, opts ...ClientOption) (Client, error)
NewClient 统一的客户端创建函数,创建 HTTP 客户端。
注意:此实现位于扩展包中,需要单独引入:
go get github.com/rushteam/reckit/ext/feast/http
func NewClientWithContext ¶
func NewClientWithContext(ctx context.Context, endpoint, project string, opts ...ClientOption) (Client, error)
NewClientWithContext 带上下文的客户端创建函数
type ClientConfig ¶
type ClientConfig struct {
// Endpoint 服务端点
Endpoint string
// Project 项目名称
Project string
// Timeout 超时时间
Timeout time.Duration
// UseGRPC 是否使用 gRPC(默认 false,使用 HTTP)
UseGRPC bool
// Auth 认证信息
Auth *AuthConfig
}
ClientConfig Feast 客户端配置
type DefaultClientFactory ¶
type DefaultClientFactory struct{}
DefaultClientFactory 是默认的 Feast HTTP 客户端工厂。
func (*DefaultClientFactory) NewClient ¶
func (f *DefaultClientFactory) NewClient(ctx context.Context, endpoint, project string, opts ...ClientOption) (Client, error)
NewClient 创建 Feast HTTP 客户端
type Feature ¶
type Feature struct {
// Name 特征名称,例如 "driver_hourly_stats:conv_rate"
Name string
// FeatureView 特征视图名称,例如 "driver_hourly_stats"
FeatureView string
// ValueType 特征值类型,例如 "FLOAT", "INT64", "STRING"
ValueType string
// Description 特征描述
Description string
}
Feature 特征定义
type FeatureMapping ¶
type FeatureMapping struct {
// UserFeatures 用户特征列表,例如 ["user_stats:age", "user_stats:gender"]
UserFeatures []string
// ItemFeatures 物品特征列表,例如 ["item_stats:price", "item_stats:category"]
ItemFeatures []string
// RealtimeFeatures 实时特征列表,例如 ["interaction:click_count", "interaction:view_count"]
RealtimeFeatures []string
// UserEntityKey 用户实体键名,默认 "user_id"
UserEntityKey string
// ItemEntityKey 物品实体键名,默认 "item_id"
ItemEntityKey string
}
FeatureMapping 特征映射配置
type FeatureServiceAdapter ¶
type FeatureServiceAdapter struct {
// contains filtered or unexported fields
}
FeatureServiceAdapter 将 Feast Client 适配为 core.FeatureService 接口。
注意:此实现位于扩展包中,需要单独引入:
go get github.com/rushteam/reckit/ext/feast/http
这是推荐的使用方式:通过适配器将 Feast(基础设施层)适配为 core.FeatureService(领域层)。
func NewFeatureServiceAdapter ¶
func NewFeatureServiceAdapter(client Client, mapping *FeatureMapping) *FeatureServiceAdapter
NewFeatureServiceAdapter 创建一个新的 FeatureService 适配器。
参数:
- client: Feast 客户端(基础设施层)
- mapping: 特征映射配置
返回:
- *FeatureServiceAdapter: 实现了 core.FeatureService 接口的适配器
func (*FeatureServiceAdapter) BatchGetItemFeatures ¶
func (a *FeatureServiceAdapter) BatchGetItemFeatures(ctx context.Context, itemIDs []string) (map[string]map[string]float64, error)
BatchGetItemFeatures 批量获取物品特征
func (*FeatureServiceAdapter) BatchGetRealtimeFeatures ¶
func (a *FeatureServiceAdapter) BatchGetRealtimeFeatures(ctx context.Context, pairs []core.FeatureUserItemPair) (map[core.FeatureUserItemPair]map[string]float64, error)
BatchGetRealtimeFeatures 批量获取实时特征
func (*FeatureServiceAdapter) BatchGetUserFeatures ¶
func (a *FeatureServiceAdapter) BatchGetUserFeatures(ctx context.Context, userIDs []string) (map[string]map[string]float64, error)
BatchGetUserFeatures 批量获取用户特征
func (*FeatureServiceAdapter) Close ¶
func (a *FeatureServiceAdapter) Close(ctx context.Context) error
Close 关闭特征服务(实现 core.FeatureService 接口)
func (*FeatureServiceAdapter) GetItemFeatures ¶
func (a *FeatureServiceAdapter) GetItemFeatures(ctx context.Context, itemID string) (map[string]float64, error)
GetItemFeatures 获取物品特征
func (*FeatureServiceAdapter) GetRealtimeFeatures ¶
func (a *FeatureServiceAdapter) GetRealtimeFeatures(ctx context.Context, userID, itemID string) (map[string]float64, error)
GetRealtimeFeatures 获取实时特征
func (*FeatureServiceAdapter) GetUserFeatures ¶
func (a *FeatureServiceAdapter) GetUserFeatures(ctx context.Context, userID string) (map[string]float64, error)
GetUserFeatures 获取用户特征
type FeatureServiceInfo ¶
type FeatureServiceInfo struct {
// Endpoint 服务端点
Endpoint string
// Project 项目名称
Project string
// FeatureViews 特征视图列表
FeatureViews []string
// OnlineStore 在线存储类型
OnlineStore string
// OfflineStore 离线存储类型
OfflineStore string
}
FeatureServiceInfo 特征服务信息
type FeatureVector ¶
type FeatureVector struct {
// Values 特征值,key 为特征名称,value 为特征值
Values map[string]interface{}
// EntityRow 对应的实体行
EntityRow map[string]interface{}
}
FeatureVector 特征向量
type GetHistoricalFeaturesRequest ¶
type GetHistoricalFeaturesRequest struct {
// EntityDF 实体数据框(包含实体 ID 和时间戳)
EntityDF []map[string]interface{}
// Features 特征名称列表
Features []string
// StartTime 开始时间(可选)
StartTime *time.Time
// EndTime 结束时间(可选)
EndTime *time.Time
// Project 项目名称(可选)
Project string
}
GetHistoricalFeaturesRequest 获取历史特征请求
type GetHistoricalFeaturesResponse ¶
type GetHistoricalFeaturesResponse struct {
// DataFrame 历史特征数据框
DataFrame []map[string]interface{}
// Metadata 元数据
Metadata map[string]interface{}
}
GetHistoricalFeaturesResponse 获取历史特征响应
type GetOnlineFeaturesRequest ¶
type GetOnlineFeaturesRequest struct {
// Features 特征名称列表,例如 ["driver_hourly_stats:conv_rate", "driver_hourly_stats:acc_rate"]
Features []string
// EntityRows 实体行,例如 [{"driver_id": 1001}, {"driver_id": 1002}]
EntityRows []map[string]interface{}
// Project 项目名称(可选)
Project string
}
GetOnlineFeaturesRequest 获取在线特征请求
type GetOnlineFeaturesResponse ¶
type GetOnlineFeaturesResponse struct {
// FeatureVectors 特征向量列表,每个元素对应一个实体行
FeatureVectors []FeatureVector
// Metadata 元数据
Metadata map[string]interface{}
}
GetOnlineFeaturesResponse 获取在线特征响应
type HTTPClient ¶
type HTTPClient struct {
// Endpoint 服务端点,例如 "http://localhost:6566"
Endpoint string
// Project 项目名称
Project string
// Timeout 超时时间
Timeout time.Duration
// Auth 认证信息
Auth *AuthConfig
// contains filtered or unexported fields
}
HTTPClient 是 Feast Feature Store 的 HTTP 客户端实现。
注意:此实现位于扩展包中,需要单独引入:
go get github.com/rushteam/reckit/ext/feast/http
func NewHTTPClient ¶
func NewHTTPClient(endpoint, project string, opts ...ClientOption) (*HTTPClient, error)
NewHTTPClient 创建一个新的 Feast HTTP 客户端。
func (*HTTPClient) GetFeatureService ¶
func (c *HTTPClient) GetFeatureService(ctx context.Context) (*FeatureServiceInfo, error)
GetFeatureService 获取特征服务信息
func (*HTTPClient) GetHistoricalFeatures ¶
func (c *HTTPClient) GetHistoricalFeatures(ctx context.Context, req *GetHistoricalFeaturesRequest) (*GetHistoricalFeaturesResponse, error)
GetHistoricalFeatures 获取历史特征
func (*HTTPClient) GetOnlineFeatures ¶
func (c *HTTPClient) GetOnlineFeatures(ctx context.Context, req *GetOnlineFeaturesRequest) (*GetOnlineFeaturesResponse, error)
GetOnlineFeatures 获取在线特征
func (*HTTPClient) ListFeatures ¶
func (c *HTTPClient) ListFeatures(ctx context.Context) ([]Feature, error)
ListFeatures 列出所有可用的特征
func (*HTTPClient) Materialize ¶
func (c *HTTPClient) Materialize(ctx context.Context, req *MaterializeRequest) error
Materialize 将特征物化到在线存储