Ana içeriğe geç

Dapr Service Task (Type: 3)

Dapr Service Task, Dapr service invocation özelliği kullanarak mikroservislere çağrı yapmak için kullanılan görev türüdür. Doğrudan Dapr SDK üzerinden service invocation API'sini kullanır.

Görev Tanımı

Schema: task-definition.schema.json

{
"key": "invoke-user-service",
"version": "1.0.0",
"domain": "core",
"flow": "sys-tasks",
"flowVersion": "1.0.0",
"tags": ["service", "invocation", "user"],
"attributes": {
"type": "3",
"config": {
"appId": "user-service",
"methodName": "GetUserProfile",
"httpVerb": "GET",
"body": {
"userId": "user-123"
},
"headers": {
"Content-Type": "application/json"
},
"queryString": "version=v1&include=profile",
"timeoutSeconds": 30
}
}
}

Konfigürasyon Alanları

AlanTipZorunluVarsayılanAçıklama
appIdstringEvet-Hedef service app ID
methodNamestringEvet-Çağrılacak method/endpoint
httpVerbstringHayır-HTTP metodu (GET, POST, PUT, DELETE, PATCH)
bodyobjectHayırnullRequest data
headersobjectHayırnullHTTP header'ları
queryStringstringHayırnullQuery string parametreleri
timeoutSecondsintegerHayır30İstek timeout süresi (saniye, minimum: 1)
acceptedStatusCodesstring[]Hayır-Başarılı kabul edilecek HTTP hata kodları. Exact kod ("403", "404") ve wildcard pattern ("4xx", "40x") destekler.

Property Erişimi

PropertySetter MetoduAçıklama
AppIdSetAppId(string appId)Hedef service app ID
MethodNameSetMethodName(string methodName)Çağrılacak method
HttpVerbRead-onlyTanım dosyasında ayarlanır
BodySetBody(dynamic body)Request body
HeadersSetHeaders(Dictionary<string, string?> headers)Tüm header'ları set eder
-AddHeader(string key, string? value)Tekil header ekler/günceller
-RemoveHeader(string key)Tekil header kaldırır
QueryStringSetQueryString(string? queryString)Query string
TimeoutSecondsRead-onlyTanım dosyasında ayarlanır
AcceptedStatusCodesRead-onlyTanım dosyasında ayarlanır

Standart Yanıt

{
"data": {
"profile": {
"userId": "123",
"name": "John Doe",
"email": "john@example.com"
}
},
"isSuccess": true,
"errorMessage": null,
"metadata": {
"appId": "user-service",
"methodName": "GetUserProfile",
"httpVerb": "GET"
},
"executionDurationMs": 120,
"taskType": "DaprServiceTask"
}

Sık Karşılaşılan Sorunlar

ProblemÇözüm
Service not foundApp ID ve service discovery configuration'ını kontrol edin
Method not allowedHTTP verb ve method name uyumunu kontrol edin
Circuit breaker openDownstream service health'ini kontrol edin
Authentication failedToken ve RBAC policies'i doğrulayın