Documentation
¶
Index ¶
- Constants
- func Open(ctx context.Context, dsn string) (*sql.DB, error)
- func RunMigrations(ctx context.Context, db *sql.DB) error
- type EntityFactRepository
- func (r *EntityFactRepository) InvalidateEntityRelation(ctx context.Context, ...) error
- func (r *EntityFactRepository) ListByEntityRelation(ctx context.Context, tenantID, entity, relation string, limit int) ([]domain.EntityFact, error)
- func (r *EntityFactRepository) Store(ctx context.Context, fact domain.EntityFact) (domain.EntityFact, error)
- func (r *EntityFactRepository) StoreBatch(ctx context.Context, facts []domain.EntityFact) ([]domain.EntityFact, error)
- type MemoryRepository
- func (r *MemoryRepository) ClaimPostprocessJobs(ctx context.Context, opts domain.MemoryPostprocessClaimOptions) ([]domain.MemoryPostprocessJob, error)
- func (r *MemoryRepository) Count(ctx context.Context) (int64, error)
- func (r *MemoryRepository) Delete(ctx context.Context, tenantID, memoryID string) error
- func (r *MemoryRepository) EnqueuePostprocessJobs(ctx context.Context, jobs []domain.MemoryPostprocessJobEnqueue, ...) ([]domain.MemoryPostprocessJob, error)
- func (r *MemoryRepository) FindByCanonicalKey(ctx context.Context, tenantID, canonicalKey string) (*domain.Memory, error)
- func (r *MemoryRepository) GetByIDs(ctx context.Context, tenantID string, ids []string) ([]domain.Memory, error)
- func (r *MemoryRepository) GetPostprocessJob(ctx context.Context, jobID string) (*domain.MemoryPostprocessJob, error)
- func (r *MemoryRepository) ListBySourceTurnHash(ctx context.Context, tenantID, sourceTurnHash string, limit int) ([]domain.Memory, error)
- func (r *MemoryRepository) ListPostprocessJobs(ctx context.Context, filter domain.MemoryPostprocessJobFilter) ([]domain.MemoryPostprocessJob, error)
- func (r *MemoryRepository) MarkIndexState(ctx context.Context, tenantID string, memoryIDs []string, ...) error
- func (r *MemoryRepository) MarkPostprocessJobFailed(ctx context.Context, jobID string, now time.Time, nextAvailable time.Time, ...) error
- func (r *MemoryRepository) MarkPostprocessJobSucceeded(ctx context.Context, jobID string, now time.Time) error
- func (r *MemoryRepository) Search(ctx context.Context, tenantID, query string, topK int) ([]domain.Memory, error)
- func (r *MemoryRepository) SearchWithFilters(ctx context.Context, tenantID, query string, topK int, ...) ([]domain.Memory, error)
- func (r *MemoryRepository) Store(ctx context.Context, m domain.Memory) (domain.Memory, error)
- func (r *MemoryRepository) StoreBatch(ctx context.Context, memories []domain.Memory) ([]domain.Memory, error)
- func (r *MemoryRepository) StoreBatchAsyncIngest(ctx context.Context, items []domain.MemoryAsyncIngestItem, maxAttempts int) (domain.MemoryIngestReceipt, error)
- func (r *MemoryRepository) Touch(ctx context.Context, tenantID string, ids []string) error
- type TenantRepository
- func (r *TenantRepository) Count(ctx context.Context) (int64, error)
- func (r *TenantRepository) Create(ctx context.Context, t domain.Tenant) (domain.Tenant, error)
- func (r *TenantRepository) Exists(ctx context.Context, tenantID string) (bool, error)
- func (r *TenantRepository) List(ctx context.Context, limit int) ([]domain.Tenant, error)
- func (r *TenantRepository) ListMemoryCounts(ctx context.Context, tenantIDs []string) (map[string]int64, error)
- func (r *TenantRepository) MemoryCount(ctx context.Context, tenantID string) (int64, error)
Constants ¶
View Source
const ( InsertTenantSQL = ` INSERT INTO tenants(id, name, created_at) VALUES (?, ?, ?) ` TenantExistsSQL = ` SELECT EXISTS(SELECT 1 FROM tenants WHERE id = ?) ` CountTenantsSQL = ` SELECT COUNT(1) FROM tenants ` CountTenantMemoriesSQL = ` SELECT COUNT(1) FROM memories WHERE tenant_id = ? ` ListTenantMemoryCountsSQL = ` SELECT tenant_id, COUNT(1) AS memory_count FROM memories WHERE tenant_id IN (%s) GROUP BY tenant_id ` ListTenantsSQL = ` SELECT id, name, created_at FROM tenants ORDER BY created_at DESC LIMIT ? ` CountMemoriesSQL = ` SELECT COUNT(1) FROM memories ` InsertMemorySQL = `` /* 366-byte string literal not displayed */ DeleteMemorySQL = ` DELETE FROM memories WHERE tenant_id = ? AND id = ? ` SearchMemoriesSQL = `` /* 510-byte string literal not displayed */ ListMemoriesRecentSQL = `` /* 347-byte string literal not displayed */ InsertMemoryFTSSQL = ` INSERT INTO memory_fts(content, tenant_id, memory_id) VALUES (?, ?, ?) ` DeleteMemoryFTSSQL = ` DELETE FROM memory_fts WHERE tenant_id = ? AND memory_id = ? ` GetMemoriesByIDsBaseSQL = `` /* 314-byte string literal not displayed */ FindMemoryByCanonicalKeySQL = `` /* 346-byte string literal not displayed */ ListMemoriesBySourceTurnHashSQL = `` /* 487-byte string literal not displayed */ InsertEntityFactSQL = `` /* 900-byte string literal not displayed */ ListEntityFactsByEntityRelationSQL = `` /* 250-byte string literal not displayed */ InvalidateEntityFactsByRelationSQL = `` /* 222-byte string literal not displayed */ UpsertMemoryIndexJobSQL = `` /* 487-byte string literal not displayed */ UpdateMemoryIndexJobStateSQL = `` /* 204-byte string literal not displayed */ UpsertMemoryPostprocessJobSQL = `` /* 538-byte string literal not displayed */ GetMemoryPostprocessJobIDSQL = ` SELECT id FROM memory_postprocess_jobs WHERE tenant_id = ? AND memory_id = ? AND job_type = ? LIMIT 1 ` GetMemoryPostprocessJobByIDSQL = `` /* 213-byte string literal not displayed */ ListMemoryPostprocessJobsBaseSQL = `` /* 192-byte string literal not displayed */ ListMemoryPostprocessJobIDsForClaimSQL = `` /* 198-byte string literal not displayed */ MarkMemoryPostprocessJobClaimedSQL = ` UPDATE memory_postprocess_jobs SET status = 'running', lease_owner = ?, leased_until = ?, updated_at = ? WHERE id = ? ` MarkMemoryPostprocessJobSucceededSQL = `` /* 144-byte string literal not displayed */ MarkMemoryPostprocessJobFailedSQL = `` /* 167-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EntityFactRepository ¶
type EntityFactRepository struct {
// contains filtered or unexported fields
}
func NewEntityFactRepository ¶
func NewEntityFactRepository(db *sql.DB) *EntityFactRepository
func (*EntityFactRepository) InvalidateEntityRelation ¶
func (*EntityFactRepository) ListByEntityRelation ¶
func (r *EntityFactRepository) ListByEntityRelation( ctx context.Context, tenantID, entity, relation string, limit int, ) ([]domain.EntityFact, error)
func (*EntityFactRepository) Store ¶
func (r *EntityFactRepository) Store(ctx context.Context, fact domain.EntityFact) (domain.EntityFact, error)
func (*EntityFactRepository) StoreBatch ¶
func (r *EntityFactRepository) StoreBatch(ctx context.Context, facts []domain.EntityFact) ([]domain.EntityFact, error)
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
func NewMemoryRepository ¶
func NewMemoryRepository(db *sql.DB) *MemoryRepository
func (*MemoryRepository) ClaimPostprocessJobs ¶
func (r *MemoryRepository) ClaimPostprocessJobs( ctx context.Context, opts domain.MemoryPostprocessClaimOptions, ) ([]domain.MemoryPostprocessJob, error)
func (*MemoryRepository) Count ¶
func (r *MemoryRepository) Count(ctx context.Context) (int64, error)
func (*MemoryRepository) Delete ¶
func (r *MemoryRepository) Delete(ctx context.Context, tenantID, memoryID string) error
func (*MemoryRepository) EnqueuePostprocessJobs ¶
func (r *MemoryRepository) EnqueuePostprocessJobs( ctx context.Context, jobs []domain.MemoryPostprocessJobEnqueue, defaultMaxAttempts int, ) ([]domain.MemoryPostprocessJob, error)
func (*MemoryRepository) FindByCanonicalKey ¶
func (*MemoryRepository) GetPostprocessJob ¶
func (r *MemoryRepository) GetPostprocessJob(ctx context.Context, jobID string) (*domain.MemoryPostprocessJob, error)
func (*MemoryRepository) ListBySourceTurnHash ¶
func (*MemoryRepository) ListPostprocessJobs ¶
func (r *MemoryRepository) ListPostprocessJobs( ctx context.Context, filter domain.MemoryPostprocessJobFilter, ) ([]domain.MemoryPostprocessJob, error)
func (*MemoryRepository) MarkIndexState ¶
func (r *MemoryRepository) MarkIndexState( ctx context.Context, tenantID string, memoryIDs []string, op domain.MemoryIndexOperation, state domain.MemoryIndexState, lastError string, ) error
func (*MemoryRepository) MarkPostprocessJobFailed ¶
func (*MemoryRepository) MarkPostprocessJobSucceeded ¶
func (*MemoryRepository) SearchWithFilters ¶
func (r *MemoryRepository) SearchWithFilters( ctx context.Context, tenantID, query string, topK int, filters domain.MemorySearchFilters, ) ([]domain.Memory, error)
func (*MemoryRepository) StoreBatch ¶
func (*MemoryRepository) StoreBatchAsyncIngest ¶
func (r *MemoryRepository) StoreBatchAsyncIngest( ctx context.Context, items []domain.MemoryAsyncIngestItem, maxAttempts int, ) (domain.MemoryIngestReceipt, error)
type TenantRepository ¶
type TenantRepository struct {
// contains filtered or unexported fields
}
func NewTenantRepository ¶
func NewTenantRepository(db *sql.DB) *TenantRepository
func (*TenantRepository) Count ¶
func (r *TenantRepository) Count(ctx context.Context) (int64, error)
func (*TenantRepository) ListMemoryCounts ¶
func (*TenantRepository) MemoryCount ¶
Click to show internal directories.
Click to hide internal directories.