feat(grpc): add gRPC server infrastructure and schedule sync service

Add gRPC server support with configurable TLS, environment-based settings, and Wire injection. Implement schedule synchronization service with task runner integration for external course data fetching.

- Add gRPC configuration with env var overrides (APP_GRPC_ENABLED, APP_GRPC_PORT, etc.)
- Create gRPC server infrastructure with runner task management
- Implement ScheduleSyncService for course data synchronization
- Add sync endpoint to schedule handler for external system integration
- Update repository with context-aware batch delete operation
- Wire all dependencies including zap logger for structured logging
This commit is contained in:
2026-03-13 20:40:20 +08:00
parent cf36b1350d
commit c561a0bb0c
20 changed files with 3241 additions and 5 deletions

17
internal/config/grpc.go Normal file
View File

@@ -0,0 +1,17 @@
package config
import "fmt"
// GRPCConfig gRPC 服务器配置
type GRPCConfig struct {
Enabled bool `mapstructure:"enabled"`
Port int `mapstructure:"port"`
TLSEnabled bool `mapstructure:"tls_enabled"`
TLSCertFile string `mapstructure:"tls_cert_file"`
TLSKeyFile string `mapstructure:"tls_key_file"`
}
// Address 返回 gRPC 服务器监听地址
func (c *GRPCConfig) Address() string {
return fmt.Sprintf(":%d", c.Port)
}