refactor: introduce service layer and migrate gRPC handlers to use it
All checks were successful
Build / build (push) Successful in 2m17s
All checks were successful
Build / build (push) Successful in 2m17s
Extract business logic from gRPC handlers into a dedicated service package. Add context support throughout for cancellation and timeouts. Move models to their own package, remove hardcoded credentials from config, and simplify parsers to only handle HTML parsing.
This commit is contained in:
@@ -7,25 +7,26 @@ import (
|
||||
|
||||
var ErrLoginFailed = errors.New("login failed")
|
||||
|
||||
type ScheduleError struct {
|
||||
// AppError 携带操作名(Op)与中文提示(Msg)的错误类型,用于统一日志与错误上报。
|
||||
type AppError struct {
|
||||
Op string
|
||||
Err error
|
||||
Msg string
|
||||
}
|
||||
|
||||
func (e *ScheduleError) Error() string {
|
||||
func (e *AppError) Error() string {
|
||||
if e.Msg != "" {
|
||||
return fmt.Sprintf("%s: %s: %v", e.Op, e.Msg, e.Err)
|
||||
}
|
||||
return fmt.Sprintf("%s: %v", e.Op, e.Err)
|
||||
}
|
||||
|
||||
func (e *ScheduleError) Unwrap() error {
|
||||
func (e *AppError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
func New(op string, err error, msg string) error {
|
||||
return &ScheduleError{
|
||||
return &AppError{
|
||||
Op: op,
|
||||
Err: err,
|
||||
Msg: msg,
|
||||
|
||||
Reference in New Issue
Block a user