refactor: introduce service layer and migrate gRPC handlers to use it
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:
lafay
2026-06-16 18:33:13 +08:00
parent ae9297c11c
commit ab37aeb2fc
26 changed files with 603 additions and 683 deletions

View File

@@ -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,