(deps commandDeps)
| 1054 | } |
| 1055 | |
| 1056 | func newMemoryExtractorDrainCommand(deps commandDeps) *cobra.Command { |
| 1057 | var timeoutRaw string |
| 1058 | |
| 1059 | cmd := &cobra.Command{ |
| 1060 | Use: memoryDrainKey, |
| 1061 | Short: "Drain Memory v2 extractor work", |
| 1062 | Args: cobra.NoArgs, |
| 1063 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 1064 | client, err := clientFromDeps(deps) |
| 1065 | if err != nil { |
| 1066 | return err |
| 1067 | } |
| 1068 | timeout := 60 * time.Second |
| 1069 | if strings.TrimSpace(timeoutRaw) != "" { |
| 1070 | parsed, err := time.ParseDuration(strings.TrimSpace(timeoutRaw)) |
| 1071 | if err != nil { |
| 1072 | return fmt.Errorf("memory.extractor.timeout_invalid: %w", err) |
| 1073 | } |
| 1074 | timeout = parsed |
| 1075 | } |
| 1076 | ctx, cancel := context.WithTimeout(cmd.Context(), timeout) |
| 1077 | defer cancel() |
| 1078 | response, err := client.DrainMemoryExtractor(ctx) |
| 1079 | if err != nil { |
| 1080 | return err |
| 1081 | } |
| 1082 | return writeCommandOutput(cmd, memoryObjectBundle("Memory Extractor Drain", response)) |
| 1083 | }, |
| 1084 | } |
| 1085 | cmd.Flags().StringVar(&timeoutRaw, "timeout", "60s", "Maximum drain wait duration") |
| 1086 | return cmd |
| 1087 | } |
| 1088 | |
| 1089 | func newMemoryExtractorDisableCommand() *cobra.Command { |
| 1090 | var sessionID string |
no test coverage detected