MCPcopy Create free account
hub / github.com/temporalio/temporal / AdminForceUnloadTaskQueuePartition

Function AdminForceUnloadTaskQueuePartition

tools/tdbg/task_queue_commands.go:230–295  ·  view source on GitHub ↗

AdminForceUnloadTaskQueuePartition forcefully unloads a task queue partition

(c *cli.Context, clientFactory ClientFactory)

Source from the content-addressed store, hash-verified

228
229// AdminForceUnloadTaskQueuePartition forcefully unloads a task queue partition
230func AdminForceUnloadTaskQueuePartition(c *cli.Context, clientFactory ClientFactory) error {
231 // extracting the namespace
232 namespace, err := getRequiredOption(c, FlagNamespace)
233 if err != nil {
234 return err
235 }
236
237 // extracting the task queue name
238 tqName, err := getRequiredOption(c, FlagTaskQueue)
239 if err != nil {
240 return err
241 }
242
243 // extracting the task queue type
244 tqTypeString, err := getRequiredOption(c, FlagTaskQueueType)
245 if err != nil {
246 return err
247 }
248
249 tlTypeInt, err := StringToEnum(tqTypeString, enumspb.TaskQueueType_value)
250 if err != nil {
251 return fmt.Errorf("invalid task queue type: %w", err)
252 }
253 tqType := enumspb.TaskQueueType(tlTypeInt)
254 if tqType == enumspb.TASK_QUEUE_TYPE_UNSPECIFIED {
255 return errors.New("invalid task queue type") // nolint
256 }
257
258 // extracting the task queue partition id
259 partitionID := 0
260 if c.IsSet(FlagPartitionID) {
261 partitionID = c.Int(FlagPartitionID)
262 }
263
264 // extracting the task queue partition sticky name
265 stickyName := ""
266 if c.IsSet(FlagStickyName) {
267 stickyName = c.String(FlagStickyName)
268 }
269
270 tqPartition := &taskqueuespb.TaskQueuePartition{
271 TaskQueue: tqName,
272 TaskQueueType: tqType,
273 }
274 if stickyName != "" {
275 tqPartition.PartitionId = &taskqueuespb.TaskQueuePartition_StickyName{StickyName: stickyName}
276 } else {
277 tqPartition.PartitionId = &taskqueuespb.TaskQueuePartition_NormalPartitionId{NormalPartitionId: int32(partitionID)}
278 }
279
280 client := clientFactory.AdminClient(c)
281 req := &adminservice.ForceUnloadTaskQueuePartitionRequest{
282 Namespace: namespace,
283 TaskQueuePartition: tqPartition,
284 }
285
286 ctx, cancel := newContext(c)
287 defer cancel()

Callers 1

Calls 10

getRequiredOptionFunction · 0.85
StringToEnumFunction · 0.85
prettyPrintJSONObjectFunction · 0.85
IntMethod · 0.80
newContextFunction · 0.70
NewMethod · 0.65
StringMethod · 0.65
AdminClientMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected