Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCUMENTATION: Support Brokers Abstraction v2.10.3 #300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 68 additions & 7 deletions 1. Brokers/1. Brokers.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ namespace OtripleS.Web.Api.Brokers.Storages
}
```

###### For IStorageBroker.Students.cs:
#### For IStorageBroker.Students.cs:
```csharp
using system;
using system.Linq;
Expand All @@ -297,16 +297,16 @@ namespace OtripleS.Web.Api.Brokers.Storages
{
public partial interface IStorageBroker
{
public ValueTask<Student> InsertStudentAsync(Student student);
public ValueTask<IQueryable<Student>> SelectAllStudentsAsync();
public ValueTask<Student> SelectStudentByIdAsync(Guid studentId);
public ValueTask<Student> UpdateStudentAsync(Student student);
public ValueTask<Student> DeleteStudentAsync(Student student);
ValueTask<Student> InsertStudentAsync(Student student);
ValueTask<IQueryable<Student>> SelectAllStudentsAsync();
ValueTask<Student> SelectStudentByIdAsync(Guid studentId);
ValueTask<Student> UpdateStudentAsync(Student student);
ValueTask<Student> DeleteStudentAsync(Student student);
}
}
```

###### For StorageBroker.Students.cs:
#### For StorageBroker.Students.cs:
```csharp
using System;
using System.Linq;
Expand Down Expand Up @@ -338,6 +338,67 @@ namespace OtripleS.Web.Api.Brokers.Storages
}
```

### Support Brokers:

#### For IDateTimeBroker.cs:
```csharp
public interface IDateTimeBroker
{
ValueTask<DateTimeOffset> GetCurrentDateTimeOffsetAsync();
}
```

#### For DateTimeBroker.cs:
```csharp
public class DateTimeBroker : IDateTimeBroker
{
public async ValueTask<DateTimeOffset> GetCurrentDateTimeOffsetAsync() =>
DateTimeOffset.UtcNow;
}
```

#### For ILoggingBroker.cs:
```csharp
public interface ILoggingBroker
{
ValueTask LogInformationAsync(string message);
ValueTask LogTraceAsync(string message);
ValueTask LogDebugAsync(string message);
ValueTask LogWarningAsync(string message);
ValueTask LogErrorAsync(Exception exception);
ValueTask LogCriticalAsync(Exception exception);
}
```

#### For LoggingBroker.cs:
```csharp
public class LoggingBroker : ILoggingBroker
{
private readonly ILogger<LoggingBroker> logger;

public LoggingBroker(ILogger<LoggingBroker> logger) =>
this.logger = logger;

public async ValueTask LogInformationAsync(string message) =>
this.logger.LogInformation(message);

public async ValueTask LogTraceAsync(string message) =>
this.logger.LogTrace(message);

public async ValueTask LogDebugAsync(string message) =>
this.logger.LogDebug(message);

public async ValueTask LogWarningAsync(string message) =>
this.logger.LogWarning(message);

public async ValueTask LogErrorAsync(Exception exception) =>
this.logger.LogError(exception.Message, exception);

public async ValueTask LogCriticalAsync(Exception exception) =>
this.logger.LogCritical(exception, exception.Message);
}
```

## 1.6 Summary
Brokers are the first layer of abstraction between your business logic and the outside world. But they are not the only layer of abstraction because a few native models will still leak through your brokers to your broker-neighboring services. It is natural to avoid doing any mappings outside the realm of logic, in our case, the foundation services.

Expand Down
8 changes: 4 additions & 4 deletions 2. Services/2.1 Foundations/2.1 Foundations.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ private StudentValidationException CreateAndLogValidationException(Xeption excep
message: "Student validation error occurred, please check your input and try again.",
innerException: exception);

this.loggingBroker.LogError(studentValidationException);
this.loggingBroker.LogErrorAsync(studentValidationException);

return studentValidationException;
}
Expand Down Expand Up @@ -700,7 +700,7 @@ private StudentValidationException CreateAndLogValidationException(Xeption excep
message: "Student validation error occurred, please check your input and try again.",
innerException: exception);

this.loggingBroker.LogError(studentValidationException);
this.loggingBroker.LogErrorAsync(studentValidationException);

return studentValidationException;
}
Expand Down Expand Up @@ -963,7 +963,7 @@ private StudentValidationException CreateAndLogValidationException(Xeption excep
message: "Invalid input, contact support.",
innerException: exception);

this.loggingBroker.LogError(studentValidationException);
this.loggingBroker.LogErrorAsync(studentValidationException);

return studentValidationException;
}
Expand Down Expand Up @@ -1142,7 +1142,7 @@ private StudentDependencyValidationException CreateAndLogDependencyValidationExc
message: "Student dependency validation error occurred, please try again.",
innerException: exception);

this.loggingBroker.LogError(studentDependencyValidationException);
this.loggingBroker.LogErrorAsync(studentDependencyValidationException);

return studentDependencyValidationException;
}
Expand Down
2 changes: 1 addition & 1 deletion 2. Services/2.3 Orchestrations/2.3 Orchestrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ public partial class StudentOrchestrationService
message: "Student dependency validation error occurred, fix errors and try again",
exception.innerException as Xeption);

this.loggingBroker.LogError(studentOrchestrationDependencyValidationException);
this.loggingBroker.LogErrorAsync(studentOrchestrationDependencyValidationException);

return studentOrchestrationDependencyValidationException;
}
Expand Down
Loading