feat: seed default plugins/pipelines, auto-enqueue jobs on asset ingest
- Migration seeds metadata_extractor, sidecar_sync, no_op plugins - Pipelines: extract_metadata → metadata_extractor, sync_sidecar → sidecar_sync - Worker reacts to AssetIngested → enqueues ExtractMetadata job - Worker reacts to SidecarSyncRequested → enqueues SyncSidecar job - Closes the ingest-to-processing loop end-to-end
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
-- Default plugins matching worker's InMemoryPluginRegistry
|
||||
INSERT INTO plugins (plugin_id, name, plugin_type, is_enabled, configuration)
|
||||
VALUES
|
||||
('a0000000-0000-4000-8000-000000000001', 'metadata_extractor', 'media_processor', true, '{}'),
|
||||
('a0000000-0000-4000-8000-000000000002', 'sidecar_sync', 'sidecar_writer', true, '{}'),
|
||||
('a0000000-0000-4000-8000-000000000003', 'no_op', 'scheduled_task', true, '{}')
|
||||
ON CONFLICT (plugin_id) DO NOTHING;
|
||||
|
||||
-- Pipeline: extract_metadata → metadata_extractor
|
||||
INSERT INTO processing_pipelines (pipeline_id, trigger_event, steps)
|
||||
VALUES (
|
||||
'b0000000-0000-4000-8000-000000000001',
|
||||
'extract_metadata',
|
||||
'[{"plugin_id": "a0000000-0000-4000-8000-000000000001", "step_order": 0, "configuration": {}}]'
|
||||
)
|
||||
ON CONFLICT (pipeline_id) DO NOTHING;
|
||||
|
||||
-- Pipeline: sync_sidecar → sidecar_sync
|
||||
INSERT INTO processing_pipelines (pipeline_id, trigger_event, steps)
|
||||
VALUES (
|
||||
'b0000000-0000-4000-8000-000000000002',
|
||||
'sync_sidecar',
|
||||
'[{"plugin_id": "a0000000-0000-4000-8000-000000000002", "step_order": 0, "configuration": {}}]'
|
||||
)
|
||||
ON CONFLICT (pipeline_id) DO NOTHING;
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
ports::EventStore,
|
||||
value_objects::SystemId,
|
||||
errors::DomainError, events::DomainEvent, ports::EventStore, value_objects::SystemId,
|
||||
};
|
||||
use event_payload::EventPayload;
|
||||
use uuid::Uuid;
|
||||
@@ -19,8 +16,9 @@ fn aggregate_id(event: &DomainEvent) -> Uuid {
|
||||
| DomainEvent::AssetDeleted { asset_id, .. }
|
||||
| DomainEvent::SidecarSyncRequested { asset_id, .. } => *asset_id.as_uuid(),
|
||||
|
||||
DomainEvent::ShareCreated { scope_id, .. }
|
||||
| DomainEvent::ShareRevoked { scope_id, .. } => *scope_id.as_uuid(),
|
||||
DomainEvent::ShareCreated { scope_id, .. } | DomainEvent::ShareRevoked { scope_id, .. } => {
|
||||
*scope_id.as_uuid()
|
||||
}
|
||||
|
||||
DomainEvent::JobEnqueued { job_id, .. }
|
||||
| DomainEvent::JobCompleted { job_id, .. }
|
||||
@@ -33,8 +31,8 @@ impl EventStore for PostgresEventStore {
|
||||
async fn append(&self, event: &DomainEvent) -> Result<(), DomainError> {
|
||||
let payload = EventPayload::from(event);
|
||||
let event_type = payload.subject().to_string();
|
||||
let json = serde_json::to_value(&payload)
|
||||
.map_err(|e| DomainError::Internal(e.to_string()))?;
|
||||
let json =
|
||||
serde_json::to_value(&payload).map_err(|e| DomainError::Internal(e.to_string()))?;
|
||||
let agg_id = aggregate_id(event);
|
||||
|
||||
sqlx::query(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::helpers::{pg_repo, MapDomainError};
|
||||
use crate::helpers::{MapDomainError, pg_repo};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use domain::{
|
||||
|
||||
Reference in New Issue
Block a user