eric-sse 0.7.2.dev1__tar.gz → 0.7.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.3
2
2
  Name: eric-sse
3
- Version: 0.7.2.dev1
3
+ Version: 0.7.4
4
4
  Summary: A lightweight message dispatcher based on SSE protocol data transfer objects format
5
5
  License: MIT
6
6
  Keywords: sse,queue,concurrency
@@ -154,6 +154,8 @@ class AbstractChannel(ABC):
154
154
  async def message_stream(self, listener: MessageQueueListener) -> AsyncIterable[Any]:
155
155
  """
156
156
  Entry point for message streaming
157
+
158
+ A message with type = 'error' is yeld on invalid listener or channel
157
159
  """
158
160
 
159
161
  def new_messages():
@@ -5,7 +5,7 @@ from eric_sse import get_logger
5
5
  from eric_sse.entities import AbstractChannel, MessageQueueListener
6
6
  from eric_sse.message import Message, SignedMessage, MessageContract
7
7
  from eric_sse.exception import NoMessagesException
8
- from eric_sse.queue import AbstractMessageQueueFactory, InMemoryMessageQueueFactory
8
+ from eric_sse.queue import AbstractMessageQueueFactory
9
9
 
10
10
  logger = get_logger()
11
11
 
@@ -9,8 +9,9 @@ from typing import AsyncIterable
9
9
 
10
10
  from eric_sse import get_logger
11
11
  from eric_sse.message import MessageContract, Message
12
- from eric_sse.exception import InvalidChannelException, InvalidListenerException, InvalidMessageFormat
12
+ from eric_sse.exception import InvalidChannelException, InvalidMessageFormat
13
13
  from eric_sse.prefabs import SSEChannel
14
+ from eric_sse.queue import AbstractMessageQueueFactory
14
15
 
15
16
  logger = get_logger()
16
17
 
@@ -21,10 +22,10 @@ class SSEChannelContainer:
21
22
  def __init__(self):
22
23
  self.__channels: dict[str: SSEChannel] = {}
23
24
 
24
- def add(self) -> SSEChannel:
25
- channel = SSEChannel()
25
+ def add(self, queues_factory: AbstractMessageQueueFactory | None = None) -> SSEChannel:
26
+ channel = SSEChannel(queues_factory=queues_factory)
26
27
  if channel.id in self.__channels:
27
- raise InvalidListenerException(f'Channel with id {channel.id} already exists')
28
+ raise InvalidChannelException(f'Channel with id {channel.id} already exists')
28
29
  self.__channels[channel.id] = channel
29
30
  return channel
30
31
 
@@ -35,7 +36,10 @@ class SSEChannelContainer:
35
36
  raise InvalidChannelException(f'No channel with id {channel_id}')
36
37
 
37
38
  def rm(self, channel_id: str):
38
- del self.__channels[channel_id]
39
+ try:
40
+ del self.__channels[channel_id]
41
+ except KeyError:
42
+ raise InvalidChannelException(f'No channel with id {channel_id}')
39
43
 
40
44
 
41
45
  class SocketServer:
@@ -2,7 +2,7 @@
2
2
  name = "eric-sse"
3
3
  description = "A lightweight message dispatcher based on SSE protocol data transfer objects format"
4
4
  requires-python = ">=3.10, <3.12"
5
- version = "0.7.2.dev1"
5
+ version = "0.7.4"
6
6
  authors = [
7
7
  {name = "Luca Stretti", email = "laxertu@gmail.com"}
8
8
  ]
File without changes
File without changes