Asenkron İşlemler
Uzun Süre Çalışan İşlemler
Geri aramalar, webhooklar ve gerçek zamanlı durum güncellemeleri ile asenkron işlemleri yönetin.
Asenkron İşleme Başla
POST /api/{tenantId}/{projectId}/async/operation
Uzun süre çalışan asenkron bir işlemi başlatır ve takip için bir işlem ID'si döner. Geri arama URL'lerini ve webhook bildirimlerini destekler.
Parametreler
| Parametre | Tür | Konum | Açıklama |
|---|---|---|---|
tenantId |
GUID | Yol | Kiracı tanımlayıcısı |
projectId |
GUID | Yol | Proje tanımlayıcısı |
İstek Gövdesi
{
"operationType": "ProcessMiningAnalysis",
"operationName": "Kapsamlı Müşteri Yolculuğu Analizi",
"operationDescription": "Gelişmiş ML algoritmaları ile müşteri etkileşim desenlerinin derin analizi",
"priority": "High",
"parameters": {
"datasetId": "880e8400-e29b-41d4-a716-446655440000",
"analysisType": "comprehensive",
"timeWindow": {
"startDate": "2024-01-01",
"endDate": "2024-01-31"
},
"algorithmSettings": {
"useAdvancedML": true,
"enableAnomalyDetection": true,
"performanceOptimization": "high_accuracy"
},
"outputOptions": {
"generateReports": true,
"createVisualizations": true,
"exportFormats": ["PDF", "CSV", "JSON"]
}
},
"callbacks": {
"onProgress": "https://your-app.com/webhooks/progress",
"onCompletion": "https://your-app.com/webhooks/completion",
"onError": "https://your-app.com/webhooks/error"
},
"notifications": {
"email": ["analyst@company.com", "manager@company.com"],
"slack": {
"channel": "#process-mining",
"mentionUsers": ["@analyst", "@data-team"]
}
},
"timeout": 7200,
"retryPolicy": {
"maxRetries": 3,
"retryDelay": 300,
"backoffMultiplier": 2.0
}
}
Yanıt
{
"operationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"operationType": "ProcessMiningAnalysis",
"operationName": "Kapsamlı Müşteri Yolculuğu Analizi",
"status": "Initiated",
"estimatedDuration": "45-60 dakika",
"estimatedCompletion": "2024-01-20T12:15:00Z",
"trackingUrl": "/api/{tenantId}/{projectId}/async/operation/op-ff0e8400-e29b-41d4-a716-446655440000",
"webhooksRegistered": 3,
"priority": "High",
"dateCreated": "2024-01-20T11:15:00Z",
"timeoutAt": "2024-01-20T13:15:00Z",
"resourcesAllocated": {
"cpuUnits": 4,
"memoryGB": 8,
"estimatedCost": "$2.45"
}
}
İşlem Durumunu Getir
GET /api/{tenantId}/{projectId}/async/operation/{operationId}
Asenkron işlemin mevcut durumunu ve ilerlemesini, detaylı yürütme bilgileri ve tahmini tamamlama süreleri dahil olmak üzere getirir.
Parametreler
| Parametre | Tür | Konum | Açıklama |
|---|---|---|---|
operationId |
string | Yol | İşlem tanımlayıcısı |
Yanıt
{
"operationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"operationType": "ProcessMiningAnalysis",
"operationName": "Kapsamlı Müşteri Yolculuğu Analizi",
"status": "Running",
"progress": {
"percentage": 67,
"currentPhase": "Makine Öğrenimi Analizi",
"phasesCompleted": 2,
"totalPhases": 3,
"startTime": "2024-01-20T11:18:00Z",
"elapsedTime": "23 dakika 15 saniye",
"estimatedRemaining": "15-20 dakika",
"estimatedCompletion": "2024-01-20T12:05:00Z"
},
"execution": {
"executionId": "exec-aa1e8400-e29b-41d4-a716-446655440000",
"workerNode": "async-worker-03",
"resourceUsage": {
"cpuUsage": 78,
"memoryUsage": "6.2 GB",
"diskUsage": "1.3 GB",
"networkIO": "45 MB"
},
"processedRecords": 125430,
"totalRecords": 187250,
"processingRate": "dakikada 1890 kayıt"
},
"phases": [
{
"phaseName": "Veri Yükleme ve Doğrulama",
"status": "Completed",
"startTime": "2024-01-20T11:18:00Z",
"endTime": "2024-01-20T11:25:00Z",
"duration": "7 dakika",
"recordsProcessed": 187250,
"validationResults": {
"validRecords": 187248,
"errorRecords": 2,
"dataQualityScore": 99.9
}
},
{
"phaseName": "Süreç Keşfi",
"status": "Completed",
"startTime": "2024-01-20T11:25:00Z",
"endTime": "2024-01-20T11:38:00Z",
"duration": "13 dakika",
"results": {
"activitiesDiscovered": 52,
"processVariants": 347,
"uniquePaths": 289
}
},
{
"phaseName": "Makine Öğrenimi Analizi",
"status": "Running",
"startTime": "2024-01-20T11:38:00Z",
"progress": 72,
"currentActivity": "Anomali tespiti modellerinin eğitimi",
"modelsTraining": 3,
"modelsCompleted": 2
},
{
"phaseName": "Rapor Oluşturma",
"status": "Pending",
"estimatedStartTime": "2024-01-20T11:55:00Z",
"estimatedDuration": "8-10 dakika"
}
],
"callbacks": {
"progressCallbacksSent": 15,
"lastProgressCallback": "2024-01-20T11:40:00Z",
"callbacksSuccessful": 15,
"callbacksFailed": 0
},
"dateCreated": "2024-01-20T11:15:00Z",
"timeoutAt": "2024-01-20T13:15:00Z",
"priority": "High"
}
Asenkron İşlemleri Listele
GET /api/{tenantId}/{projectId}/async/operations
Filtreleme ve sayfalama seçenekleri ile asenkron işlemler listesini getirir. Birden çok uzun süreli işlemin izlenmesi için faydalıdır.
Sorgu Parametreleri
| Parametre | Tür | Açıklama |
|---|---|---|
status |
string | Duruma göre filtreleme: Initiated, Running, Completed, Failed, Cancelled, Timeout |
operationType |
string | İşlem türüne göre filtreleme: ProcessMiningAnalysis, DataEnrichment, ReportGeneration |
priority |
string | Önceliğe göre filtreleme: Low, Normal, High, Critical |
dateFrom |
datetime | Bu tarihten itibaren işlemleri filtrele |
dateTo |
datetime | Bu tarihe kadar işlemleri filtrele |
includeDetails |
boolean | Detaylı yürütme bilgilerini dahil et (varsayılan: false) |
page |
integer | Sayfalama için sayfa numarası (varsayılan: 1) |
pageSize |
integer | Sayfa başına öğe sayısı (varsayılan: 20, max: 100) |
Yanıt
{
"operations": [
{
"operationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"operationType": "ProcessMiningAnalysis",
"operationName": "Kapsamlı Müşteri Yolculuğu Analizi",
"status": "Running",
"progress": 67,
"priority": "High",
"startTime": "2024-01-20T11:18:00Z",
"estimatedCompletion": "2024-01-20T12:05:00Z",
"currentPhase": "Makine Öğrenimi Analizi",
"resourceUsage": {
"cpuUsage": 78,
"memoryUsage": "6.2 GB"
}
},
{
"operationId": "op-gg1e8400-e29b-41d4-a716-446655440000",
"operationType": "DataEnrichment",
"operationName": "Satış Verisi İşleme",
"status": "Completed",
"progress": 100,
"priority": "Normal",
"startTime": "2024-01-20T10:45:00Z",
"endTime": "2024-01-20T11:10:00Z",
"duration": "25 dakika",
"recordsProcessed": 89420
}
],
"summary": {
"totalOperations": 47,
"running": 3,
"completed": 41,
"failed": 2,
"cancelled": 1
},
"page": 1,
"pageSize": 20,
"hasNextPage": true
}
Asenkron İşlemi İptal Et
DELETE /api/{tenantId}/{projectId}/async/operation/{operationId}
Çalışan veya bekleyen bir asenkron işlemi iptal eder. İşlem zarifçe durdurulur ve tamamlanan işler korunur.
İstek Gövdesi (Opsiyonel)
{
"reason": "Değişen gereksinimler nedeniyle kullanıcı iptali",
"preservePartialResults": true,
"forceTermination": false,
"notifyCallbacks": true
}
Yanıt
{
"operationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"status": "Cancelled",
"cancellationTime": "2024-01-20T11:42:00Z",
"reason": "Değişen gereksinimler nedeniyle kullanıcı iptali",
"progressAtCancellation": 67,
"phaseAtCancellation": "Makine Öğrenimi Analizi",
"partialResults": {
"available": true,
"completedPhases": 2,
"downloadUrls": [
"https://api.mindzie.com/downloads/partial-results-ff0e8400.zip"
]
},
"resourcesReleased": {
"cpuUnits": 4,
"memoryGB": 8,
"costSaved": "$1.20"
},
"cancelledBy": "user123"
}
İşlem Sonuçlarını Getir
GET /api/{tenantId}/{projectId}/async/operation/{operationId}/results
Tamamlanmış bir asenkron işlemin tüm üretilen çıktıları, raporları ve indirilebilir materyalleri ile birlikte sonuçlarını getirir.
Sorgu Parametreleri
| Parametre | Tür | Açıklama |
|---|---|---|
format |
string | Yanıt formatı: summary, detailed, download (varsayılan: summary) |
includeArtifacts |
boolean | İndirilebilir materyalleri dahil et (varsayılan: true) |
phase |
string | Sadece belirtilen fazın sonuçlarını al |
Yanıt
{
"operationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"operationType": "ProcessMiningAnalysis",
"operationName": "Kapsamlı Müşteri Yolculuğu Analizi",
"status": "Completed",
"completionTime": "2024-01-20T12:03:00Z",
"totalDuration": "45 dakika",
"success": true,
"summary": {
"recordsAnalyzed": 187248,
"processVariants": 347,
"anomaliesDetected": 23,
"modelsGenerated": 3,
"reportsCreated": 5,
"dataQualityScore": 94.7,
"overallConfidenceScore": 91.2
},
"phaseResults": [
{
"phaseName": "Veri Yükleme ve Doğrulama",
"status": "Completed",
"results": {
"recordsLoaded": 187250,
"validRecords": 187248,
"dataQualityScore": 99.9,
"validationErrors": [
{
"type": "Eksik Zaman Damgası",
"count": 2,
"resolved": true
}
]
}
},
{
"phaseName": "Süreç Keşfi",
"status": "Completed",
"results": {
"processModel": {
"activities": 52,
"transitions": 178,
"variants": 347,
"complexity": "Orta-Yüksek"
},
"performanceMetrics": {
"averageCycleTime": "4.2 saat",
"medianCycleTime": "3.1 saat",
"bottleneckActivities": ["Başvuruyu İnceleme", "Yönetici Onayı"],
"efficiency": 78.3
}
}
},
{
"phaseName": "Makine Öğrenimi Analizi",
"status": "Completed",
"results": {
"anomalies": {
"detected": 23,
"highSeverity": 5,
"mediumSeverity": 12,
"lowSeverity": 6,
"falsePositiveRate": 0.03
},
"predictions": {
"cycleTimePrediction": {
"accuracy": 0.89,
"meanAbsoluteError": "0.3 saat"
},
"pathPrediction": {
"accuracy": 0.92,
"confidence": 0.87
}
},
"patterns": {
"frequentPatterns": 15,
"rarePatterns": 8,
"criticalPaths": 3
}
}
}
],
"artifacts": [
{
"name": "Süreç Madenciliği Analiz Raporu",
"type": "Report",
"format": "PDF",
"size": "3.2 MB",
"downloadUrl": "https://api.mindzie.com/downloads/report-ff0e8400.pdf",
"description": "Öngörüler ve öneriler içeren kapsamlı analiz raporu"
},
{
"name": "Süreç Modeli Görselleştirmesi",
"type": "Visualization",
"format": "SVG",
"size": "890 KB",
"downloadUrl": "https://api.mindzie.com/downloads/process-map-ff0e8400.svg",
"description": "Etkileşimli süreç akış diyagramı"
},
{
"name": "Anomali Tespit Sonuçları",
"type": "Dataset",
"format": "CSV",
"size": "1.8 MB",
"downloadUrl": "https://api.mindzie.com/downloads/anomalies-ff0e8400.csv",
"description": "Detaylı anomali analizi ve şiddet skorları"
},
{
"name": "Tahmin Modelleri",
"type": "Model",
"format": "PKL",
"size": "45.7 MB",
"downloadUrl": "https://api.mindzie.com/downloads/models-ff0e8400.zip",
"description": "Döngü süresi ve yol tahmini için eğitilmiş ML modelleri"
}
],
"performance": {
"totalExecutionTime": "45 dakika",
"resourceUtilization": {
"averageCpuUsage": 72,
"peakMemoryUsage": "7.8 GB",
"totalCpuHours": 3.0,
"totalCost": "$2.31"
},
"throughput": "dakikada 4161 kayıt",
"efficiency": 87.2
},
"recommendations": [
{
"category": "Süreç Optimizasyonu",
"priority": "High",
"recommendation": "'Yönetici Onayı' faaliyetinde bekleme sürelerinin azaltılmasına odaklanın",
"expectedImprovement": "Toplam döngü süresinde %25 azalma"
},
{
"category": "Veri Kalitesi",
"priority": "Medium",
"recommendation": "Otomatik zaman damgası doğrulaması uygulayın",
"expectedImprovement": "Veri kalite skorunda %99.5 iyileşme"
}
]
}
Webhook Kaydı Yap
POST /api/{tenantId}/{projectId}/async/webhooks
Asenkron işlemlerle ilgili gerçek zamanlı bildirimler almak için webhook ucu kaydeder. Birden çok etkinlik türünü ve özel filtrelemeyi destekler.
İstek Gövdesi
{
"webhookUrl": "https://your-app.com/webhooks/async-operations",
"webhookName": "Ana İşlemler Webhook",
"events": [
"operation.started",
"operation.progress",
"operation.phase.completed",
"operation.completed",
"operation.failed",
"operation.cancelled"
],
"filters": {
"operationTypes": ["ProcessMiningAnalysis", "DataEnrichment"],
"priorities": ["High", "Critical"],
"minProgressIncrement": 10
},
"authentication": {
"type": "hmac-sha256",
"secret": "your-webhook-secret-key"
},
"retryPolicy": {
"maxRetries": 5,
"retryDelay": 60,
"backoffMultiplier": 2.0,
"maxDelay": 3600
},
"headers": {
"X-Source": "mindzie-api",
"X-Environment": "production"
}
}
Yanıt
{
"webhookId": "wh-123e8400-e29b-41d4-a716-446655440000",
"webhookUrl": "https://your-app.com/webhooks/async-operations",
"webhookName": "Ana İşlemler Webhook",
"status": "Active",
"eventsSubscribed": [
"operation.started",
"operation.progress",
"operation.phase.completed",
"operation.completed",
"operation.failed",
"operation.cancelled"
],
"filters": {
"operationTypes": ["ProcessMiningAnalysis", "DataEnrichment"],
"priorities": ["High", "Critical"],
"minProgressIncrement": 10
},
"createdAt": "2024-01-20T11:45:00Z",
"lastDelivery": null,
"deliveryStats": {
"totalDeliveries": 0,
"successfulDeliveries": 0,
"failedDeliveries": 0,
"averageResponseTime": null
}
}
Başarısız İşlemi Tekrar Dene
POST /api/{tenantId}/{projectId}/async/operation/{operationId}/retry
Opsiyonel parametre değişiklikleriyle başarısız bir asenkron işlemi tekrar dener. Hata noktası veya tamamen yeniden başlatılabilir.
İstek Gövdesi
{
"retryMode": "resume",
"retryReason": "Altyapı sorunu çözüldü, artırılmış kaynaklarla yeniden deneme",
"modifyParameters": true,
"updatedParameters": {
"algorithmSettings": {
"useAdvancedML": true,
"enableAnomalyDetection": true,
"performanceOptimization": "high_throughput"
},
"resourceAllocation": {
"cpuUnits": 6,
"memoryGB": 12,
"priority": "Critical"
}
},
"retryPolicy": {
"maxRetries": 2,
"retryDelay": 180,
"backoffMultiplier": 1.5
},
"newTimeout": 10800,
"preserveOriginalResults": true
}
Yanıt
{
"originalOperationId": "op-ff0e8400-e29b-41d4-a716-446655440000",
"newOperationId": "op-retry-ff0e8400-e29b-41d4-a716-446655440000",
"retryMode": "resume",
"retryNumber": 1,
"resumeFromPhase": "Makine Öğrenimi Analizi",
"status": "Initiated",
"estimatedDuration": "20-25 dakika",
"estimatedCompletion": "2024-01-20T12:30:00Z",
"preservedResults": {
"phasesPreserved": 2,
"recordsProcessed": 187248,
"progressSaved": 45
},
"resourcesAllocated": {
"cpuUnits": 6,
"memoryGB": 12,
"estimatedCost": "$3.20"
},
"retryAttemptDate": "2024-01-20T12:05:00Z"
}
Toplu İşlemleri Gönder
POST /api/{tenantId}/{projectId}/async/batch
Bağımlılıklar ve koordinasyon ile birden çok asenkron işlemi toplu olarak gönderir. Birden çok bağlı işlem gerektiren karmaşık iş akışları için faydalıdır.
İstek Gövdesi
{
"batchName": "Aylık Süreç Madenciliği Boru Hattı",
"batchDescription": "Birden çok veri seti ile tam aylık analiz iş akışı",
"operations": [
{
"operationName": "Veri Hazırlama",
"operationType": "DataEnrichment",
"priority": "High",
"operationKey": "data-prep",
"parameters": {
"datasetId": "dataset-1",
"cleaningRules": ["remove_duplicates", "fix_timestamps"],
"outputFormat": "processed_csv"
}
},
{
"operationName": "Süreç Keşfi",
"operationType": "ProcessMiningAnalysis",
"priority": "High",
"operationKey": "discovery",
"dependencies": ["data-prep"],
"parameters": {
"algorithm": "alpha_miner_enhanced",
"enableVariantAnalysis": true
}
},
{
"operationName": "Performans Analizi",
"operationType": "ProcessMiningAnalysis",
"priority": "Normal",
"operationKey": "performance",
"dependencies": ["discovery"],
"parameters": {
"enableBottleneckDetection": true,
"generateOptimizationRecommendations": true
}
}
],
"batchCallbacks": {
"onBatchStart": "https://your-app.com/webhooks/batch-start",
"onOperationComplete": "https://your-app.com/webhooks/operation-complete",
"onBatchComplete": "https://your-app.com/webhooks/batch-complete"
},
"failurePolicy": {
"stopOnFirstFailure": false,
"continueIndependentOperations": true,
"retryFailedOperations": true
}
}
Yanıt
{
"batchId": "batch-567e8400-e29b-41d4-a716-446655440000",
"batchName": "Aylık Süreç Madenciliği Boru Hattı",
"status": "Initiated",
"operations": [
{
"operationKey": "data-prep",
"operationId": "op-prep-890e8400-e29b-41d4-a716-446655440000",
"status": "Running",
"dependencies": [],
"estimatedDuration": "15 dakika"
},
{
"operationKey": "discovery",
"operationId": "op-disc-901e8400-e29b-41d4-a716-446655440000",
"status": "Pending",
"dependencies": ["data-prep"],
"estimatedStartTime": "2024-01-20T12:20:00Z"
},
{
"operationKey": "performance",
"operationId": "op-perf-012e8400-e29b-41d4-a716-446655440000",
"status": "Pending",
"dependencies": ["discovery"],
"estimatedStartTime": "2024-01-20T12:45:00Z"
}
],
"totalOperations": 3,
"estimatedBatchDuration": "75-90 dakika",
"estimatedBatchCompletion": "2024-01-20T13:45:00Z",
"batchStartTime": "2024-01-20T12:05:00Z",
"trackingUrl": "/api/{tenantId}/{projectId}/async/batch/batch-567e8400-e29b-41d4-a716-446655440000"
}
Örnek: Tam Asenkron İşlem İş Akışı
Bu örnek, asenkron işlemlerin tüm yaşam döngüsünü gösterir:
// 1. Gerçek zamanlı bildirimler için webhook kaydı
const registerWebhook = async () => {
const response = await fetch('/api/{tenantId}/{projectId}/async/webhooks', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
webhookUrl: 'https://your-app.com/webhooks/async-operations',
webhookName: 'Process Mining Webhook',
events: [
'operation.started',
'operation.progress',
'operation.completed',
'operation.failed'
],
filters: {
operationTypes: ['ProcessMiningAnalysis'],
priorities: ['High', 'Critical'],
minProgressIncrement: 15
},
authentication: {
type: 'hmac-sha256',
secret: 'your-secret-key'
}
})
});
return await response.json();
};
// 2. Karmaşık bir asenkron işlemi başlat
const startAsyncAnalysis = async () => {
const response = await fetch('/api/{tenantId}/{projectId}/async/operation', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
operationType: 'ProcessMiningAnalysis',
operationName: 'Gelişmiş Müşteri Yolculuğu Analizi',
operationDescription: 'Anomali tespiti ile derin ML destekli analiz',
priority: 'High',
parameters: {
datasetId: '880e8400-e29b-41d4-a716-446655440000',
analysisType: 'comprehensive',
timeWindow: {
startDate: '2024-01-01',
endDate: '2024-01-31'
},
algorithmSettings: {
useAdvancedML: true,
enableAnomalyDetection: true,
performanceOptimization: 'high_accuracy'
},
outputOptions: {
generateReports: true,
createVisualizations: true,
exportFormats: ['PDF', 'CSV', 'JSON']
}
},
callbacks: {
onProgress: 'https://your-app.com/webhooks/progress',
onCompletion: 'https://your-app.com/webhooks/completion',
onError: 'https://your-app.com/webhooks/error'
},
notifications: {
email: ['analyst@company.com'],
slack: {
channel: '#process-mining',
mentionUsers: ['@analyst']
}
},
timeout: 7200
})
});
return await response.json();
};
// 3. İşlem ilerlemesini izle
const monitorOperation = async (operationId) => {
const checkStatus = async () => {
const response = await fetch(`/api/{tenantId}/{projectId}/async/operation/${operationId}`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
const operation = await response.json();
console.log(`İşlem ${operationId}: ${operation.status} (%${operation.progress.percentage})`);
console.log(`Mevcut faz: ${operation.progress.currentPhase}`);
console.log(`Tahmini tamamlanma: ${operation.progress.estimatedCompletion}`);
if (operation.status === 'Running') {
setTimeout(() => checkStatus(), 60000); // Her dakika kontrol et
} else if (operation.status === 'Completed') {
console.log('İşlem başarıyla tamamlandı!');
await getOperationResults(operationId);
} else if (operation.status === 'Failed') {
console.log('İşlem başarısız oldu, yeniden deniyor...');
await retryOperation(operationId);
}
};
await checkStatus();
};
// 4. İşlem sonuçlarını al
const getOperationResults = async (operationId) => {
const response = await fetch(`/api/{tenantId}/{projectId}/async/operation/${operationId}/results?format=detailed&includeArtifacts=true`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
const results = await response.json();
console.log('İşlem Sonuçları:', results.summary);
console.log('Oluşturulan Materyaller:');
results.artifacts.forEach(artifact => {
console.log(`- ${artifact.name} (${artifact.format}): ${artifact.downloadUrl}`);
});
return results;
};
// 5. Başarısız işlemi yeniden dene
const retryOperation = async (operationId) => {
const response = await fetch(`/api/{tenantId}/{projectId}/async/operation/${operationId}/retry`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
retryMode: 'resume',
retryReason: 'Artırılmış kaynaklarla otomatik yeniden deneme',
modifyParameters: true,
updatedParameters: {
resourceAllocation: {
cpuUnits: 6,
memoryGB: 12,
priority: 'Critical'
}
},
newTimeout: 10800
})
});
const retryResult = await response.json();
console.log(`Yeniden deneme işlemi başladı: ${retryResult.newOperationId}`);
// Yeniden deneme işlemini izle
await monitorOperation(retryResult.newOperationId);
return retryResult;
};
// 6. Toplu işlemleri gönder
const submitBatchOperations = async () => {
const response = await fetch('/api/{tenantId}/{projectId}/async/batch', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
batchName: 'Tam Süreç Madenciliği Boru Hattı',
batchDescription: 'Veri hazırlama ve raporlamayla uçtan uca analiz',
operations: [
{
operationName: 'Veri Temizleme',
operationType: 'DataEnrichment',
priority: 'High',
operationKey: 'clean',
parameters: {
datasetId: 'raw-dataset-123',
cleaningRules: ['remove_duplicates', 'fix_timestamps', 'validate_activities']
}
},
{
operationName: 'Süreç Analizi',
operationType: 'ProcessMiningAnalysis',
priority: 'High',
operationKey: 'analyze',
dependencies: ['clean'],
parameters: {
analysisType: 'comprehensive',
enableML: true,
generateInsights: true
}
},
{
operationName: 'Rapor Oluşturma',
operationType: 'ReportGeneration',
priority: 'Normal',
operationKey: 'report',
dependencies: ['analyze'],
parameters: {
reportType: 'executive_summary',
includeVisualizations: true,
exportFormats: ['PDF', 'PowerPoint']
}
}
],
failurePolicy: {
stopOnFirstFailure: false,
continueIndependentOperations: true,
retryFailedOperations: true
}
})
});
return await response.json();
};
// Tam asenkron iş akışını çalıştır
const runAsyncWorkflow = async () => {
try {
console.log('Asenkron işlem iş akışı başlatılıyor...');
// Webhook kaydı yap
const webhook = await registerWebhook();
console.log(`Webhook kaydedildi: ${webhook.webhookId}`);
// İşlemi başlat
const operation = await startAsyncAnalysis();
console.log(`İşlem başladı: ${operation.operationId}`);
console.log(`Tahmini tamamlanma: ${operation.estimatedCompletion}`);
// İlerlemesini izle
await monitorOperation(operation.operationId);
} catch (error) {
console.error('Asenkron iş akışı başarısız oldu:', error);
}
};
// İş akışını çalıştır
runAsyncWorkflow();
Python Örneği
import requests
import time
import json
import hmac
import hashlib
from datetime import datetime, timedelta
class AsyncOperationManager:
def __init__(self, base_url, tenant_id, project_id, token):
self.base_url = base_url
self.tenant_id = tenant_id
self.project_id = project_id
self.headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def start_operation(self, operation_type, name, parameters, priority='Normal', timeout=3600):
"""Asenkron işlem başlatır"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/async/operation"
payload = {
'operationType': operation_type,
'operationName': name,
'priority': priority,
'parameters': parameters,
'timeout': timeout,
'callbacks': {
'onProgress': 'https://your-app.com/webhooks/progress',
'onCompletion': 'https://your-app.com/webhooks/completion',
'onError': 'https://your-app.com/webhooks/error'
}
}
response = requests.post(url, json=payload, headers=self.headers)
return response.json()
def get_operation_status(self, operation_id):
"""Mevcut işlem durumunu getirir"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/async/operation/{operation_id}"
response = requests.get(url, headers=self.headers)
return response.json()
def list_operations(self, status=None, operation_type=None, page=1, page_size=20):
"""Filtreleme ile asenkron işlemleri listeler"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/async/operations"
params = {'page': page, 'pageSize': page_size}
if status:
params['status'] = status
if operation_type:
params['operationType'] = operation_type
response = requests.get(url, params=params, headers=self.headers)
return response.json()
def cancel_operation(self, operation_id, reason="Kullanıcı iptali"):
"""Çalışan işlemi iptal eder"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/async/operation/{operation_id}"
payload = {
'reason': reason,
'preservePartialResults': True,
'notifyCallbacks': True
}
response = requests