Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #34] Support force delete topic #38

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/api/pulsar/pulsar_partitioned_topic_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class PulsarPartitionedTopicApi {
}

static Future<String> deletePartitionTopic(
String host, int port, String tenant, String namespace, String topic) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic/partitions';
String host, int port, String tenant, String namespace, String topic, bool force) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic/partitions?force=$force';
var response = await http.delete(Uri.parse(url), headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
Expand Down
5 changes: 3 additions & 2 deletions lib/api/pulsar/pulsar_topic_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class PulsarTopicApi {
return response.body;
}

static Future<String> deleteTopic(String host, int port, String tenant, String namespace, String topic) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic';
static Future<String> deleteTopic(
String host, int port, String tenant, String namespace, String topic, bool force) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic?force=$force';
var response = await http.delete(Uri.parse(url), headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class PulsarPartitionedTopicListWidgetState extends State<PulsarPartitionedTopic
DataCell(
Text(item.topic),
),
DataCellUtil.newDelDataCell(() {
vm.deletePartitionedTopic(item.topic);
DataCellUtil.newForceDelDataCell((force) {
vm.deletePartitionedTopic(item.topic, force);
}),
]));
var topicsTable = SingleChildScrollView(
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pulsar/widget/pulsar_topic_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class PulsarTopicListWidgetState extends State<PulsarTopicListWidget> {
DataCell(
Text(item.topic),
),
DataCellUtil.newDelDataCell(() {
vm.deleteTopic(item.topic);
DataCellUtil.newForceDelDataCell((force) {
vm.deleteTopic(item.topic, force);
}),
]));
var topicsTable = SingleChildScrollView(
Expand Down
2 changes: 1 addition & 1 deletion lib/vm/pulsar/pulsar_namespace_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PulsarNamespaceViewModel extends BaseLoadListPageViewModel<PulsarPartition

Future<void> deletePartitionedTopic(String topic) async {
try {
await PulsarPartitionedTopicApi.deletePartitionTopic(host, port, tenant, namespace, topic);
await PulsarPartitionedTopicApi.deletePartitionTopic(host, port, tenant, namespace, topic, false);
await fetchTopics();
} on Exception catch (e) {
opException = e;
Expand Down
4 changes: 2 additions & 2 deletions lib/vm/pulsar/pulsar_partitioned_topic_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class PulsarPartitionedTopicListViewModel extends BaseLoadListPageViewModel<Puls
}
}

Future<void> deletePartitionedTopic(String topic) async {
Future<void> deletePartitionedTopic(String topic, bool force) async {
try {
await PulsarPartitionedTopicApi.deletePartitionTopic(host, port, tenant, namespace, topic);
await PulsarPartitionedTopicApi.deletePartitionTopic(host, port, tenant, namespace, topic, force);
await fetchTopics();
} on Exception catch (e) {
opException = e;
Expand Down
4 changes: 2 additions & 2 deletions lib/vm/pulsar/pulsar_topic_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class PulsarTopicListViewModel extends BaseLoadListPageViewModel<PulsarTopicView
}
}

Future<void> deleteTopic(String topic) async {
Future<void> deleteTopic(String topic, bool force) async {
try {
await PulsarTopicApi.deleteTopic(host, port, tenant, namespace, topic);
await PulsarTopicApi.deleteTopic(host, port, tenant, namespace, topic, force);
await fetchTopics();
} on Exception catch (e) {
opException = e;
Expand Down