kaskade 2.3.2__tar.gz → 2.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaskade
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: kaskade is a terminal user interface for kafka
5
5
  Home-page: https://github.com/sauljabin/kaskade
6
6
  License: MIT
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Requires-Dist: cloup (>=3.0,<4.0)
20
20
  Requires-Dist: confluent-kafka[avro,json,protobuf] (>=2.5,<3.0)
21
- Requires-Dist: textual (>=0.72,<0.73)
21
+ Requires-Dist: textual (>=0.76,<0.77)
22
22
  Project-URL: Documentation, https://github.com/sauljabin/kaskade
23
23
  Project-URL: Repository, https://github.com/sauljabin/kaskade
24
24
  Description-Content-Type: text/markdown
@@ -3,6 +3,7 @@ from itertools import cycle
3
3
 
4
4
  from confluent_kafka.cimpl import NewTopic
5
5
  from rich.table import Table
6
+ from textual import work
6
7
  from textual.app import ComposeResult, RenderResult, App
7
8
  from textual.binding import Binding
8
9
  from textual.containers import Container
@@ -389,37 +390,49 @@ class ListTopics(Container):
389
390
  yield table
390
391
 
391
392
  def on_mount(self) -> None:
392
- self.run_worker(self.action_refresh())
393
+ self.action_refresh()
393
394
 
394
395
  def on_data_table_row_highlighted(self, data: DataTable.RowHighlighted) -> None:
395
396
  if data.row_key.value is None:
396
397
  return
397
398
  self.current_topic = self.topics.get(data.row_key.value)
398
399
 
400
+ @work
399
401
  async def action_refresh(self) -> None:
400
- table = self.query_one(DataTable)
401
- table.loading = True
402
+ self.start_table_loading()
402
403
 
403
404
  try:
404
405
  self.topics = await self.topic_service.all()
405
406
  except Exception as ex:
406
407
  notify_error(self.app, "kafka error", ex)
407
- self.run_worker(self.fill_table())
408
408
 
409
+ self.fill_table()
410
+
411
+ @work
409
412
  async def action_new(self) -> None:
410
- async def on_dismiss(result: NewTopic) -> None:
411
- if result is None:
412
- return
413
+ result: NewTopic = await self.app.push_screen_wait(CreateTopicScreen())
414
+
415
+ if result is None:
416
+ return
417
+
418
+ self.start_table_loading()
419
+
420
+ try:
421
+ self.topic_service.create([result])
422
+ await asyncio.sleep(0.5)
423
+ self.action_refresh()
424
+ except Exception as ex:
425
+ notify_error(self.app, "kafka error", ex)
413
426
 
414
- try:
415
- self.topic_service.create([result])
416
- await asyncio.sleep(0.5)
417
- self.run_worker(self.action_refresh())
418
- except Exception as ex:
419
- notify_error(self.app, "kafka error", ex)
427
+ def start_table_loading(self) -> None:
428
+ table = self.query_one(DataTable)
429
+ table.loading = True
420
430
 
421
- await self.app.push_screen(CreateTopicScreen(), on_dismiss)
431
+ def finish_table_loading(self) -> None:
432
+ table = self.query_one(DataTable)
433
+ table.loading = False
422
434
 
435
+ @work
423
436
  async def action_edit(self) -> None:
424
437
  if self.current_topic is None:
425
438
  return
@@ -437,54 +450,51 @@ class ListTopics(Container):
437
450
  retention if retention else "",
438
451
  )
439
452
 
440
- async def on_dismiss(result: bool) -> None:
441
- if not result:
442
- return
443
-
444
- if self.current_topic is None:
445
- return
446
-
447
- try:
448
- if int(edit_topic_screen.partitions) - self.current_topic.partitions_count() > 0:
449
- self.topic_service.add_partitions(
450
- self.current_topic.name, int(edit_topic_screen.partitions)
451
- )
452
-
453
- self.topic_service.edit(
454
- self.current_topic.name,
455
- {
456
- MIN_INSYNC_REPLICAS_CONFIG: edit_topic_screen.min_insync_replicas,
457
- CLEANUP_POLICY_CONFIG: edit_topic_screen.cleanup_policy,
458
- RETENTION_MS_CONFIG: edit_topic_screen.retention,
459
- },
460
- )
453
+ result: bool = await self.app.push_screen_wait(edit_topic_screen)
454
+
455
+ if not result:
456
+ return
461
457
 
462
- await asyncio.sleep(0.5)
463
- self.run_worker(self.action_refresh())
464
- except Exception as ex:
465
- notify_error(self.app, "kafka error", ex)
458
+ self.start_table_loading()
466
459
 
467
- await self.app.push_screen(edit_topic_screen, on_dismiss)
460
+ try:
461
+ if int(edit_topic_screen.partitions) - self.current_topic.partitions_count() > 0:
462
+ self.topic_service.add_partitions(
463
+ self.current_topic.name, int(edit_topic_screen.partitions)
464
+ )
465
+
466
+ self.topic_service.edit(
467
+ self.current_topic.name,
468
+ {
469
+ MIN_INSYNC_REPLICAS_CONFIG: edit_topic_screen.min_insync_replicas,
470
+ CLEANUP_POLICY_CONFIG: edit_topic_screen.cleanup_policy,
471
+ RETENTION_MS_CONFIG: edit_topic_screen.retention,
472
+ },
473
+ )
474
+
475
+ await asyncio.sleep(0.5)
476
+ self.action_refresh()
477
+ except Exception as ex:
478
+ notify_error(self.app, "kafka error", ex)
468
479
 
480
+ @work
469
481
  async def action_delete(self) -> None:
470
482
  if self.current_topic is None:
471
483
  return
472
484
 
473
- async def on_dismiss(result: bool) -> None:
474
- if not result:
475
- return
485
+ result: bool = await self.app.push_screen_wait(DeleteTopicScreen(self.current_topic))
476
486
 
477
- if self.current_topic is None:
478
- return
487
+ if not result:
488
+ return
479
489
 
480
- try:
481
- self.topic_service.delete(self.current_topic.name)
482
- await asyncio.sleep(0.5)
483
- self.run_worker(self.action_refresh())
484
- except Exception as ex:
485
- notify_error(self.app, "kafka error", ex)
490
+ self.start_table_loading()
486
491
 
487
- await self.app.push_screen(DeleteTopicScreen(self.current_topic), on_dismiss)
492
+ try:
493
+ self.topic_service.delete(self.current_topic.name)
494
+ await asyncio.sleep(0.5)
495
+ self.action_refresh()
496
+ except Exception as ex:
497
+ notify_error(self.app, "kafka error", ex)
488
498
 
489
499
  def action_describe(self) -> None:
490
500
  if self.current_topic is None:
@@ -493,16 +503,16 @@ class ListTopics(Container):
493
503
 
494
504
  def action_all(self) -> None:
495
505
  self.current_filter = None
496
- self.run_worker(self.fill_table())
506
+ self.fill_table()
497
507
 
498
508
  def action_filter(self) -> None:
499
- def on_dismiss(result: str) -> None:
509
+ def on_dismiss(result: str | None) -> None:
500
510
  self.current_filter = result
501
- self.run_worker(self.fill_table())
511
+ self.fill_table()
502
512
 
503
513
  self.app.push_screen(FilterTopicsScreen(), on_dismiss)
504
514
 
505
- async def fill_table(self) -> None:
515
+ def fill_table(self) -> None:
506
516
  table = self.query_one(DataTable)
507
517
  table.clear()
508
518
 
@@ -528,9 +538,10 @@ class ListTopics(Container):
528
538
  table.border_title = (
529
539
  f"[{SECONDARY}]topics {border_title_filter_info}\\[[{PRIMARY}]{total_count}[/]][/]"
530
540
  )
531
- table.loading = False
532
541
  table.focus()
533
542
 
543
+ self.finish_table_loading()
544
+
534
545
 
535
546
  class KaskadeAdmin(App):
536
547
  CSS_PATH = "styles.css"
@@ -3,6 +3,7 @@ from typing import Any
3
3
  from rich.style import Style
4
4
  from rich.table import Table
5
5
  from rich.theme import Theme
6
+ from textual import work
6
7
  from textual.app import App, ComposeResult, RenderResult
7
8
  from textual.binding import Binding
8
9
  from textual.containers import Container, ScrollableContainer
@@ -238,7 +239,7 @@ class ListRecords(Container):
238
239
  self.consumer.close()
239
240
 
240
241
  def on_mount(self) -> None:
241
- self.run_worker(self.action_consume())
242
+ self.action_consume()
242
243
 
243
244
  def action_all(self) -> None:
244
245
  self.key_filter, self.value_filter, self.partition_filter, self.header_filter = (
@@ -264,7 +265,7 @@ class ListRecords(Container):
264
265
  self.consumer = self._new_consumer()
265
266
  self.records = {}
266
267
  table.border_title = self._get_title()
267
- self.run_worker(self.action_consume())
268
+ self.action_consume()
268
269
 
269
270
  def action_change_chunk(self) -> None:
270
271
  def dismiss(result: int | None) -> None:
@@ -294,6 +295,7 @@ class ListRecords(Container):
294
295
  return
295
296
  self.current_record = self.records.get(data.row_key.value)
296
297
 
298
+ @work
297
299
  async def action_consume(self) -> None:
298
300
  table = self.query_one(DataTable)
299
301
  table.loading = True
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kaskade"
3
- version = "2.3.2"
3
+ version = "2.3.4"
4
4
  description = "kaskade is a terminal user interface for kafka"
5
5
  authors = ["Saúl Piña <sauljabin@gmail.com>"]
6
6
  license = "MIT"
@@ -24,7 +24,7 @@ packages = [
24
24
  [tool.poetry.dependencies]
25
25
  python = ">=3.10 <3.13"
26
26
  cloup = "^3.0"
27
- textual = "^0.72"
27
+ textual = "^0.76"
28
28
  confluent-kafka = {extras = ["avro", "json", "protobuf"], version = "^2.5"}
29
29
 
30
30
  [tool.poetry.dev-dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes