228
229
// AdminForceUnloadTaskQueuePartition forcefully unloads a task queue partition
230
>
func AdminForceUnloadTaskQueuePartition(c *cli.Context, clientFactory ClientFactory) error {
task_queue_commands.go
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
239
>
if err != nil {
240
return err
241
}
242
243
// extracting the task queue type
245
>
if err != nil {
246
return err
247
}
248
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
260
>
if c.IsSet(FlagPartitionID) {
261
>
partitionID = c.Int(FlagPartitionID)
262
>
}
263
264
// extracting the task queue partition sticky name
266
>
if c.IsSet(FlagStickyName) {
267
>
stickyName = c.String(FlagStickyName)
268
>
}
269
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
281
>
req := &adminservice.ForceUnloadTaskQueuePartitionRequest{
282
>
Namespace: namespace,
283
>
TaskQueuePartition: tqPartition,
284
>
}
285
>
286
>
ctx, cancel := newContext(c)
287
>
defer cancel()
288
>
if response, e := client.ForceUnloadTaskQueuePartition(ctx, req); e != nil {
289
return fmt.Errorf("unable to describe Task Queue Partition: %w", e)
291
>
prettyPrintJSONObject(c, response)
292
>
293
>
}
294
>
return nil
295
}