refactor(grpc): restructure task handling and migrate to slog
All checks were successful
Build / build (push) Successful in 5m28s
All checks were successful
Build / build (push) Successful in 5m28s
Refactor the gRPC client and task handling logic to improve modularity, error handling, and observability. - Split `grpc/handler.go` into specialized handler files (login, classroom, exams, grades, schedule) to reduce complexity. - Replace standard `log` with `log/slog` throughout the project for structured logging. - Refactor `grpc/client.go` to use a thread-safe connection management pattern with `sync.RWMutex`. - Remove the legacy `service` package and HTTP server implementation, transitioning the application to a pure gRPC runner mode. - Clean up `config` and `pkg/errors` to remove unused utilities and simplify the API. - Improve error reporting in parsers and HTTP clients by checking response status codes.
This commit is contained in:
@@ -5,16 +5,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidConfig = errors.New("invalid configuration")
|
||||
ErrLoginFailed = errors.New("login failed")
|
||||
ErrCaptchaFailed = errors.New("captcha recognition failed")
|
||||
ErrScheduleFailed = errors.New("failed to fetch schedule")
|
||||
ErrRecognitionFailed = errors.New("schedule recognition failed")
|
||||
ErrUnauthorized = errors.New("unauthorized access")
|
||||
ErrTimeout = errors.New("operation timeout")
|
||||
ErrConnectionFailed = errors.New("connection failed")
|
||||
)
|
||||
var ErrLoginFailed = errors.New("login failed")
|
||||
|
||||
type ScheduleError struct {
|
||||
Op string
|
||||
@@ -40,19 +31,3 @@ func New(op string, err error, msg string) error {
|
||||
Msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
func Wrap(err error, msg string) error {
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
}
|
||||
|
||||
func Join(errs ...error) error {
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func Is(err, target error) bool {
|
||||
return errors.Is(err, target)
|
||||
}
|
||||
|
||||
func As(err error, target any) bool {
|
||||
return errors.As(err, target)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user