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

Support query pulsar message by messageId #47

Merged
merged 1 commit into from
Jan 17, 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
16 changes: 15 additions & 1 deletion lib/api/pulsar/pulsar_topic_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,21 @@ class PulsarTopicApi {

static Future<String> fetchConsumerMessage(
String host, int port, String tenant, String namespace, String topic, String ledgerId, String entryId) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/ledger/$ledgerId/entry/$entryId';
var url =
'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic/ledger/$ledgerId/entry/$entryId';
var response = await http.get(Uri.parse(url), headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
if (HttpUtil.abnormal(response.statusCode)) {
log('ErrorCode is ${response.statusCode}, body is ${response.body}');
return "";
}
return response.body;
}

static Future<String> fetchMessageId(
String host, int port, String tenant, String namespace, String topic, String timestamp) async {
var url = 'http://$host:${port.toString()}/admin/v2/persistent/$tenant/$namespace/$topic/messageid/$timestamp';
var response = await http.get(Uri.parse(url), headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
});
Expand Down
8 changes: 7 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ class MessageLookup extends MessageLookupByLibrary {
"deleteTopic": MessageLookupByLibrary.simpleMessage("Delete Topic"),
"detail": MessageLookupByLibrary.simpleMessage("detail"),
"email": MessageLookupByLibrary.simpleMessage("email"),
"entryId": MessageLookupByLibrary.simpleMessage("entryId"),
"execute": MessageLookupByLibrary.simpleMessage("execute"),
"forceDelete": MessageLookupByLibrary.simpleMessage("forceDelete"),
"isLeader": MessageLookupByLibrary.simpleMessage("Is Leader"),
"languageSettings": MessageLookupByLibrary.simpleMessage("Language Settings"),
"messageList": MessageLookupByLibrary.simpleMessage("message list"),
"name": MessageLookupByLibrary.simpleMessage("name"),
"namespace": MessageLookupByLibrary.simpleMessage("namespace"),
"namespaceName": MessageLookupByLibrary.simpleMessage("Namespace Name"),
Expand All @@ -58,10 +60,14 @@ class MessageLookup extends MessageLookupByLibrary {
"producer": MessageLookupByLibrary.simpleMessage("Producer"),
"producerList": MessageLookupByLibrary.simpleMessage("Producer List"),
"refresh": MessageLookupByLibrary.simpleMessage("Refresh"),
"searchByMessageId": MessageLookupByLibrary.simpleMessage(
"Search by MessageId, type is ledgerId entryId, submit with enter key"),
"searchByMessageIdWithHint": MessageLookupByLibrary.simpleMessage(
"Search by MessageId, type is ledgerId*entryId, submit with enter key"),
"Search by MessageId, single search type should be ledgerId entryId, multi search type should be ledgerId entryId entryId, submit with enter key"),
"searchByNamespace": MessageLookupByLibrary.simpleMessage("Search by Namespace Name"),
"searchByTenant": MessageLookupByLibrary.simpleMessage("Search by Tenant Name"),
"searchByTimestampWithHint":
MessageLookupByLibrary.simpleMessage("Search MessageId by timestamp, submit with enter key"),
"searchByTopic": MessageLookupByLibrary.simpleMessage("Search by Topic Name"),
"second": MessageLookupByLibrary.simpleMessage("second"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
Expand Down
8 changes: 6 additions & 2 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ class MessageLookup extends MessageLookupByLibrary {
"deleteTopic": MessageLookupByLibrary.simpleMessage("删除 Topic"),
"detail": MessageLookupByLibrary.simpleMessage("详细信息"),
"email": MessageLookupByLibrary.simpleMessage("邮箱"),
"entryId": MessageLookupByLibrary.simpleMessage("编号"),
"execute": MessageLookupByLibrary.simpleMessage("执行"),
"forceDelete": MessageLookupByLibrary.simpleMessage("强制删除"),
"isLeader": MessageLookupByLibrary.simpleMessage("是否是主节点"),
"languageSettings": MessageLookupByLibrary.simpleMessage("语言设置"),
"messageList": MessageLookupByLibrary.simpleMessage("消息列表"),
"name": MessageLookupByLibrary.simpleMessage("名称"),
"namespace": MessageLookupByLibrary.simpleMessage("命名空间"),
"namespaceName": MessageLookupByLibrary.simpleMessage("命名空间名称"),
Expand All @@ -58,10 +60,12 @@ class MessageLookup extends MessageLookupByLibrary {
"producer": MessageLookupByLibrary.simpleMessage("生产者"),
"producerList": MessageLookupByLibrary.simpleMessage("生产者列表"),
"refresh": MessageLookupByLibrary.simpleMessage("刷新"),
"searchByMessageIdWithHint":
MessageLookupByLibrary.simpleMessage("通过messageId查询消息,格式ledgerId*entryId,按enter键进行查询。"),
"searchByMessageId": MessageLookupByLibrary.simpleMessage("通过messageId查询消息,格式ledgerId entryId,按enter键进行查询。"),
"searchByMessageIdWithHint": MessageLookupByLibrary.simpleMessage(
"通过messageId查询消息,单条查询格式ledgerId entryId,范围查询格式位ledgerId entryId entryId,按enter键进行查询。"),
"searchByNamespace": MessageLookupByLibrary.simpleMessage("按命名空间名称搜索"),
"searchByTenant": MessageLookupByLibrary.simpleMessage("按租户名称搜索"),
"searchByTimestampWithHint": MessageLookupByLibrary.simpleMessage("通过时间戳查询消息Id, 按enter键进行查询"),
"searchByTopic": MessageLookupByLibrary.simpleMessage("按 Topic 名称搜索"),
"second": MessageLookupByLibrary.simpleMessage("秒"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
Expand Down
44 changes: 42 additions & 2 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
"deleteTopic": "Delete Topic",
"detail": "detail",
"email": "email",
"entryId": "entryId",
"execute": "execute",
"forceDelete": "forceDelete",
"isLeader": "Is Leader",
"languageSettings": "Language Settings",
"messageList": "message list",
"name": "name",
"namespace": "namespace",
"namespaceName": "Namespace Name",
Expand All @@ -35,9 +37,11 @@
"producer": "Producer",
"producerList": "Producer List",
"refresh": "Refresh",
"searchByMessageIdWithHint": "Search by MessageId, type is ledgerId*entryId, submit with enter key",
"searchByMessageId": "Search by MessageId, type is ledgerId entryId, submit with enter key",
"searchByMessageIdWithHint": "Search by MessageId, single search type should be ledgerId entryId, multi search type should be ledgerId entryId entryId, submit with enter key",
"searchByNamespace": "Search by Namespace Name",
"searchByTenant": "Search by Tenant Name",
"searchByTimestampWithHint": "Search MessageId by timestamp, submit with enter key",
"searchByTopic": "Search by Topic Name",
"second": "second",
"settings": "Settings",
Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
"deleteTopic": "删除 Topic",
"detail": "详细信息",
"email": "邮箱",
"entryId": "编号",
"execute": "执行",
"forceDelete": "强制删除",
"isLeader": "是否是主节点",
"languageSettings": "语言设置",
"messageList": "消息列表",
"name": "名称",
"namespace": "命名空间",
"namespaceName": "命名空间名称",
Expand All @@ -35,9 +37,11 @@
"producer": "生产者",
"producerList": "生产者列表",
"refresh": "刷新",
"searchByMessageIdWithHint": "通过messageId查询消息,格式ledgerId*entryId,按enter键进行查询。",
"searchByMessageId": "通过messageId查询消息,格式ledgerId entryId,按enter键进行查询。",
"searchByMessageIdWithHint": "通过messageId查询消息,单条查询格式ledgerId entryId,范围查询格式位ledgerId entryId entryId,按enter键进行查询。",
"searchByNamespace": "按命名空间名称搜索",
"searchByTenant": "按租户名称搜索",
"searchByTimestampWithHint": "通过时间戳查询消息Id, 按enter键进行查询",
"searchByTopic": "按 Topic 名称搜索",
"second": "秒",
"settings": "设置",
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/pulsar/screen/pulsar_partitioned_topic.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_basic.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_consume.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_consumer.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_detail.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_producer.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/widget/pulsar_partitioned_topic_subscription.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_basic_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_consume_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_consumer_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_detail_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_producer_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_subscription_view_model.dart';
Expand Down Expand Up @@ -62,9 +62,9 @@ class _PulsarPartitionedTopicState extends State<PulsarPartitionedTopic> {
child: PulsarPartitionedTopicSubscriptionWidget(),
).build(context),
ChangeNotifierProvider(
create: (context) => PulsarPartitionedTopicConsumeViewModel(
create: (context) => PulsarPartitionedTopicConsumerViewModel(
vm.pulsarInstancePo, vm.tenantResp, vm.namespaceResp, vm.topicResp),
child: PulsarPartitionedTopicConsumeWidget(),
child: PulsarPartitionedTopicConsumerWidget(),
).build(context),
ChangeNotifierProvider(
create: (context) => PulsarPartitionedTopicProducerViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/util/exception_util.dart';
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_consume_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_partitioned_topic_consumer_view_model.dart';
import 'package:provider/provider.dart';

class PulsarPartitionedTopicConsumeWidget extends StatefulWidget {
PulsarPartitionedTopicConsumeWidget();
class PulsarPartitionedTopicConsumerWidget extends StatefulWidget {
PulsarPartitionedTopicConsumerWidget();

@override
State<StatefulWidget> createState() {
return new PulsarPartitionedTopicConsumeWidgetState();
return new PulsarPartitionedTopicConsumerWidgetState();
}
}

class PulsarPartitionedTopicConsumeWidgetState extends State<PulsarPartitionedTopicConsumeWidget> {
class PulsarPartitionedTopicConsumerWidgetState extends State<PulsarPartitionedTopicConsumerWidget> {
@override
void initState() {
super.initState();
final vm = Provider.of<PulsarPartitionedTopicConsumeViewModel>(context, listen: false);
final vm = Provider.of<PulsarPartitionedTopicConsumerViewModel>(context, listen: false);
vm.fetchConsumers();
}

@override
Widget build(BuildContext context) {
final vm = Provider.of<PulsarPartitionedTopicConsumeViewModel>(context);
final vm = Provider.of<PulsarPartitionedTopicConsumerViewModel>(context);
if (vm.loading) {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
SpinnerUtil.create();
Expand Down
Loading