# README
Usage
// USECASE
type CheckBalanceRequest struct {
Account string `json:"account"`
}
type CheckBalanceResponse struct {
Balance int64 `json:"balance"`
Currency string `json:"currency"`
}
type CheckBalanceHandler interface {
Handle(ctx context.Context, request *CheckBalanceRequest) (*CheckBalanceResponse, error)
}
// Register handlers
func RegisterPipelineHandlers(
checkBalanceHandler account.CheckBalanceHandler,
// other handers
) {
pipeline.RegisterRequestHandler(checkBalanceHandler)
// register other handlers
}
// Register behaviours
func RegisterPipelineBehaviors(
requestLoggingBehavior *RequestLoggingBehavior,
requestTracingBehavior *RequestTracingBehavior,
requestMetricBehavior *RequestMetricBehavior,
errorHandlingBehavior *ErrorHandlingBehavior,
) {
pipeline.RegisterRequestPipelineBehaviors(
requestTracingBehavior,
requestLoggingBehavior,
requestMetricBehavior,
errorHandlingBehavior,
)
}
// ERROR HANDLING FOR RECOVERING FROM PANIC
type ErrorHandlingBehavior struct {
logger logger.Logger
}
func NewErrorHandlingBehavior(logger logger.Logger) *ErrorHandlingBehavior {
return &ErrorHandlingBehavior{
logger: logger,
}
}
func (b *ErrorHandlingBehavior) Handle(ctx context.Context, request interface{}, next pipeline.RequestHandlerFunc) (res interface{}, err error) {
response, err := next(ctx)
return response, err
}
// TRACING
type RequestTracingBehavior struct {
logger logger.Logger
tracer trace.Tracer
}
func NewTracingBehavior(logger logger.Logger, tracer trace.Tracer) *RequestTracingBehavior {
return &RequestTracingBehavior{
logger: logger,
tracer: tracer,
}
}
func (b *RequestTracingBehavior) Handle(ctx context.Context, request interface{}, next pipeline.RequestHandlerFunc) (interface{}, error) {
res, err := next(ctx)
return res, err
}
// METRICS
type RequestMetricBehavior struct {
logger logger.Logger
metricer *prome.PrometheusMetricer
cfg *ServerConfig
}
func NewMetricBehavior(logger logger.Logger, metricer *prome.PrometheusMetricer, cfg *ServerConfig) *RequestMetricBehavior {
return &RequestMetricBehavior{
logger: logger,
metricer: metricer,
cfg: cfg,
}
}
func (b *RequestMetricBehavior) Handle(ctx context.Context, request interface{}, next pipeline.RequestHandlerFunc) (response interface{}, err error) {
response, err = next(ctx)
return response, err
}
// LOGGING
type RequestLoggingBehavior struct {
logger logger.Logger
}
func NewRequestLoggingBehavior(logger logger.Logger) *RequestLoggingBehavior {
return &RequestLoggingBehavior{
logger: logger,
}
}
func (b *RequestLoggingBehavior) Handle(ctx context.Context, request interface{}, next pipeline.RequestHandlerFunc) (response interface{}, err error) {
response, err = next(ctx)
return response, err
}
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Publish the notification event to its corresponding notification handler.
RegisterNotificationHandler register the notification handler to mediatr registry.
RegisterNotificationHandlerFactory register the notification handler factory to mediatr registry.
RegisterNotificationHandlers register the notification handlers to mediatr registry.
RegisterNotificationHandlersFactories register the notification handlers factories to mediatr registry.
RegisterRequestHandler register the request handler to mediatr registry.
RegisterRequestHandlerFactory register the request handler factory to mediatr registry.
RegisterRequestPipelineBehaviors register the request behaviors to mediatr registry.
Send the request to its corresponding request handler.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
PipelineBehavior is a Pipeline behavior for wrapping the inner handler.
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
RequestHandlerFunc is a continuation for the next task to execute in the pipeline.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author