zenbroker 0.1__tar.gz → 0.3__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: zenbroker
3
- Version: 0.1
3
+ Version: 0.3
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -2,8 +2,9 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="zenbroker",
5
- version="0.1",
6
- packages=find_packages(),
5
+ version="0.3",
6
+ package_dir={"": "zenbroker"},
7
+ packages=find_packages("zenbroker"),
7
8
  install_requires=[
8
9
  "pydantic>=2.0.0,<3.0.0",
9
10
  "httpx>=0.28.0,<1.0.0"
@@ -0,0 +1,7 @@
1
+ from .client import ZenbrokerClient, ZenbrokerClientOptions, PostPublishEventResponse
2
+
3
+ __all__ = [
4
+ "ZenbrokerClient",
5
+ "ZenbrokerClientOptions",
6
+ "PostPublishEventResponse"
7
+ ]
@@ -0,0 +1,44 @@
1
+ import httpx
2
+ from typing import Dict, Any
3
+ from pydantic import BaseModel, Field, HttpUrl
4
+
5
+ class ZenbrokerClientOptions(BaseModel):
6
+ base_url: HttpUrl = Field(..., description="URL of the broker service.")
7
+ application_id: str = Field(..., description="Application ID")
8
+
9
+ class PostPublishEventPayload(BaseModel):
10
+ applicationId: str = Field(..., description="Application ID")
11
+ channel: str = Field(..., description="ChannelID")
12
+ data: Dict[str, Any]
13
+
14
+ class PostPublishEventResponse(BaseModel):
15
+ message: str = Field(..., description="Message from the server")
16
+ id: str = Field(..., description="ID of the message")
17
+
18
+ class ZenbrokerClient:
19
+ def __init__(self, opts: ZenbrokerClientOptions) -> None:
20
+ self._url: str = str(opts.base_url)
21
+ self._application_id: str = str(opts.application_id)
22
+
23
+ self._api = httpx.Client(base_url=self._url)
24
+
25
+ def publish(self, channel: str, data: Dict[str, Any]) -> PostPublishEventResponse:
26
+ post_data: PostPublishEventPayload = PostPublishEventPayload(
27
+ applicationId=self._application_id,
28
+ channel=channel,
29
+ data=data
30
+ )
31
+
32
+ response = self._api.post(
33
+ url="/producer/emit",
34
+ json=post_data.model_dump()
35
+ )
36
+
37
+ response.raise_for_status()
38
+ result = response.json()
39
+
40
+ return PostPublishEventResponse(
41
+ id=result.id,
42
+ message=result.message
43
+ )
44
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zenbroker
3
- Version: 0.1
3
+ Version: 0.3
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -0,0 +1,8 @@
1
+ setup.py
2
+ zenbroker/zenbroker/__init__.py
3
+ zenbroker/zenbroker/client.py
4
+ zenbroker/zenbroker.egg-info/PKG-INFO
5
+ zenbroker/zenbroker.egg-info/SOURCES.txt
6
+ zenbroker/zenbroker.egg-info/dependency_links.txt
7
+ zenbroker/zenbroker.egg-info/requires.txt
8
+ zenbroker/zenbroker.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ zenbroker
@@ -1,6 +0,0 @@
1
- setup.py
2
- zenbroker.egg-info/PKG-INFO
3
- zenbroker.egg-info/SOURCES.txt
4
- zenbroker.egg-info/dependency_links.txt
5
- zenbroker.egg-info/requires.txt
6
- zenbroker.egg-info/top_level.txt
File without changes