@@ -25,6 +25,9 @@ type deletionObjectStore interface {
|
||||
}
|
||||
|
||||
type DeleteProcessor struct {
|
||||
viking interface {
|
||||
DeleteSubject(context.Context, string, string) error
|
||||
}
|
||||
pool *pgxpool.Pool
|
||||
redis *redis.Client
|
||||
store deletionObjectStore
|
||||
@@ -54,6 +57,12 @@ func NewDeleteProcessor(pool *pgxpool.Pool, redisClient *redis.Client, store del
|
||||
return &DeleteProcessor{pool: pool, redis: redisClient, store: store, audit: audit.NewRepository(), providerMemory: providerClient}, nil
|
||||
}
|
||||
|
||||
func (p *DeleteProcessor) ConfigureVikingMemory(memory interface {
|
||||
DeleteSubject(context.Context, string, string) error
|
||||
}) {
|
||||
p.viking = memory
|
||||
}
|
||||
|
||||
func (p *DeleteProcessor) Handle(ctx context.Context, event outbox.Event) error {
|
||||
request, err := p.loadRequest(ctx, event.AggregateID)
|
||||
if err != nil || request.id == "" || request.status == "COMPLETED" {
|
||||
@@ -205,6 +214,11 @@ func (p *DeleteProcessor) executeSubtask(ctx context.Context, request deletionRe
|
||||
_, err := p.pool.Exec(ctx, `UPDATE memory_index_entry SET embedding=NULL,provider_ref=NULL,status='DELETED',last_error=NULL,updated_at=now() WHERE tenant_id=$1::uuid AND subject_id=$2::uuid AND index_type='pgvector'`, request.tenantID, request.subjectID)
|
||||
return "COMPLETED", "", err
|
||||
case "provider_index":
|
||||
if p.viking != nil {
|
||||
if err := p.viking.DeleteSubject(ctx, request.tenantID, request.subjectID); err != nil {
|
||||
return "", "", outbox.Retryable(err)
|
||||
}
|
||||
}
|
||||
rows, err := p.pool.Query(ctx, `SELECT memory_version_id::text,provider_ref FROM memory_index_entry WHERE tenant_id=$1::uuid AND subject_id=$2::uuid AND index_type='provider' AND provider_ref IS NOT NULL AND status<>'DELETED' ORDER BY created_at,id`, request.tenantID, request.subjectID)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
|
||||
Reference in New Issue
Block a user