refactor: remove unused scheduling and cache code

This commit is contained in:
2026-09-28 12:04:21 +08:00
parent ce5e8da2ee
commit 4473f2bebd
12 changed files with 66 additions and 294 deletions
+8 -2
View File
@@ -57,12 +57,15 @@ func newRootCommand() *cobra.Command {
}
func newAgentCommand() *cobra.Command {
cfg := config.FromEnv()
cfg, configErr := config.FromEnv()
var realCall bool
cmd := &cobra.Command{
Use: "agent",
Short: "run the file-backed Agent process",
RunE: func(_ *cobra.Command, _ []string) error {
if configErr != nil {
return configErr
}
if realCall {
return runCallOnce(cfg)
}
@@ -469,13 +472,16 @@ func openDispatcherStore(cfg config.Config) (*store.Store, error) {
}
func newDispatcherCommand() *cobra.Command {
cfg := config.FromEnv()
cfg, configErr := config.FromEnv()
var configFile string
var once bool
cmd := &cobra.Command{
Use: "dispatcher",
Short: "run the single-active Dispatcher process",
RunE: func(cmd *cobra.Command, _ []string) error {
if configErr != nil {
return configErr
}
if err := cfg.LoadDispatcherFile(configFile); err != nil {
return err
}
+10
View File
@@ -2,6 +2,7 @@ package main
import (
"bytes"
"strings"
"testing"
"git.ipao.vip/rogee/go-sip/contracts"
@@ -18,6 +19,15 @@ func TestRootHasExplicitRoles(t *testing.T) {
}
}
func TestAgentRejectsInvalidMediaPortEnvironment(t *testing.T) {
t.Setenv("AGENT_CALL_MEDIA_PORT", "invalid")
root := newRootCommand()
root.SetArgs([]string{"agent"})
if err := root.Execute(); err == nil || !strings.Contains(err.Error(), "AGENT_CALL_MEDIA_PORT") {
t.Fatalf("expected invalid port error, got %v", err)
}
}
func TestWriteResultIsJSON(t *testing.T) {
var b bytes.Buffer
data, err := marshalResultForTest(map[string]string{"status": "ok"})
+4 -1
View File
@@ -11,12 +11,15 @@ import (
)
func newUploadRetryCommand() *cobra.Command {
cfg := config.FromEnv()
cfg, configErr := config.FromEnv()
var uploadID, requestID, path string
cmd := &cobra.Command{
Use: "upload-retry", Short: "explicitly request one new grant for an unsuccessful upload; never dial",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) (returnErr error) {
if configErr != nil {
return configErr
}
if uploadID == "" || requestID == "" || path == "" {
return errors.New("--upload-id, --request-id and --file are required")
}