Response
TaskHub.Shared.Response is a telemetry-aware Result Pattern implementation module, used across the TaskHub microservices
to represent outcomes of operations in a consistent, explicit, and type-safe way.
The module is designed for:
- In-process communication (pipelines, handlers, services).
- Networking (HTTP, gRPC, messaging).
- Unified error and success handling.
- Observability-friendly result propagation.
Core Idea
The module intentionly separates values-less and value-bearing results and introduces a control adaptation layer between them.
This prevents:
- Empty
data fields in API responses.
- Ambiguous success semantics.
- Implicit loss of information.
- Leakage of generics into transport contracts.
All results share a common structure:
- ResultCode: numeric code representing the outcome.
0 - success.
1 - error.
- custome codes - domain-specific errors.
- Message: textual representation of the result code (e.g.
ITEM_NOT_FOUND).
- IsSuccess: boolean flag indicating success or failure.
Only value-bearing results include Data.
Result Types
Result
Result represents an operation outcome without a value.
Used for:
- Commands execution.
- Side-effect operations.
- Validation and authorization checks.
ValueResult
ValueResult<T> represents an operation outcome with a value of type T.
Used for:
- Queries execution.
- Read models.
- Data retrieval operations.
Rules:
Data exists only on success.
- Failure is semanticaly equivalent to
Result.
OpResult
OpResult represents a value-less operation result and acts as a canonical adapter between result forms. OpResult exists to:
- Encapsulate allowed conversions between result types.
- Prevent empty data fields in responses.
Observability
All result types integrate with OpenTelemetry:
- Result metadata is attached to spans.
- Failures are reflected in span status.
Summary
Result — base outcome without data.
ValueResult<T> — outcome with data.
OpResult — canonical value-less result and adapter.
- Conversions are explicit and asymmetric.
- Empty payloads are forbidden by design.