arnelify-broker 0.5.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.
File without changes
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: arnelify-broker
3
+ Version: 0.5.4
4
+ Summary: Minimalistic dynamic library which is a broker written in C and C++.
5
+ Home-page: https://github.com/arnelify/arnelify-broker-python
6
+ Author: Arnelify
7
+ Keywords: arnelify arnelify-broker-python arnelify-broker
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+
14
+ <img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />
15
+
16
+ ![Arnelify Broker for Python](https://img.shields.io/badge/Arnelify%20Broker%20for%20Python-0.5.4-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![Python](https://img.shields.io/badge/Python-14.0.6-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-14.0.6-blue)
17
+
18
+ ## ๐Ÿš€ About
19
+ **Arnelifyยฎ Broker for Python** - is a minimalistic dynamic library which is a message broker written in C and C++.
20
+
21
+ ## ๐Ÿ“‹ Minimal Requirements
22
+ > Important: It's strongly recommended to use in a container that has been built from the gcc v14.2.0 image.
23
+ * CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
24
+ * OS: Debian 11 / MacOS 15 / Windows 10 with <a href="https://learn.microsoft.com/en-us/windows/wsl/install">WSL2</a>.
25
+ * RAM: 4 GB
26
+
27
+ ## ๐Ÿ“ฆ Installation
28
+ Installing via pip:
29
+ ```
30
+ pip install arnelify-broker
31
+ ```
32
+ ## ๐ŸŽ‰ Usage
33
+ Compile library for AMD64:
34
+ ```
35
+ make build_amd64
36
+ ```
37
+ Compile library for ARM64:
38
+ ```
39
+ make build_arm64
40
+ ```
41
+ Compiled test:
42
+ ```
43
+ make test_nuitka
44
+ ```
45
+ Run test:
46
+ ```
47
+ make test
48
+ ```
49
+ ## ๐Ÿ“š Code Examples
50
+ Configure the C/C++ IntelliSense plugin for VSCode (optional).
51
+ ```
52
+ Clang_format_fallback = Google
53
+ ```
54
+
55
+ IncludePath for VSCode (optional):
56
+ ```
57
+ "includePath": [
58
+ "/opt/homebrew/Cellar/jsoncpp/1.9.6/include/json",
59
+ "${workspaceFolder}/src/cpp",
60
+ "${workspaceFolder}/src"
61
+ ],
62
+ ```
63
+ You can find code examples <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/tests/index.py">here</a>.
64
+
65
+ ## โš–๏ธ MIT License
66
+ This software is licensed under the <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/LICENSE">MIT License</a>. The original author's name, logo, and the original name of the software must be included in all copies or substantial portions of the software.
67
+
68
+ ## ๐Ÿ› ๏ธ Contributing
69
+ Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
70
+
71
+
72
+ ## โญ Release Notes
73
+ Version 0.5.4 - Minimalistic dynamic library
74
+
75
+ We are excited to introduce the Arnelify Broker dynamic library for Python! Please note that this version is raw and still in active development.
76
+
77
+ Change log:
78
+
79
+ * Minimalistic dynamic library
80
+ * NodeJS (Bun) addon
81
+ * FFI Support
82
+
83
+ Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the broker's capabilities, and we welcome your feedback and suggestions.
84
+
85
+ ## ๐Ÿ”— Mentioned
86
+
87
+ * <a href="https://github.com/arnelify/arnelify-pod-cpp">Arnelify POD for C++</a>
88
+ * <a href="https://github.com/arnelify/arnelify-pod-python">Arnelify POD for Python</a>
89
+ * <a href="https://github.com/arnelify/arnelify-pod-node">Arnelify POD for NodeJS</a>
90
+ * <a href="https://github.com/arnelify/arnelify-react-native">Arnelify React Native</a>
@@ -0,0 +1,77 @@
1
+ <img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />
2
+
3
+ ![Arnelify Broker for Python](https://img.shields.io/badge/Arnelify%20Broker%20for%20Python-0.5.4-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![Python](https://img.shields.io/badge/Python-14.0.6-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-14.0.6-blue)
4
+
5
+ ## ๐Ÿš€ About
6
+ **Arnelifyยฎ Broker for Python** - is a minimalistic dynamic library which is a message broker written in C and C++.
7
+
8
+ ## ๐Ÿ“‹ Minimal Requirements
9
+ > Important: It's strongly recommended to use in a container that has been built from the gcc v14.2.0 image.
10
+ * CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
11
+ * OS: Debian 11 / MacOS 15 / Windows 10 with <a href="https://learn.microsoft.com/en-us/windows/wsl/install">WSL2</a>.
12
+ * RAM: 4 GB
13
+
14
+ ## ๐Ÿ“ฆ Installation
15
+ Installing via pip:
16
+ ```
17
+ pip install arnelify-broker
18
+ ```
19
+ ## ๐ŸŽ‰ Usage
20
+ Compile library for AMD64:
21
+ ```
22
+ make build_amd64
23
+ ```
24
+ Compile library for ARM64:
25
+ ```
26
+ make build_arm64
27
+ ```
28
+ Compiled test:
29
+ ```
30
+ make test_nuitka
31
+ ```
32
+ Run test:
33
+ ```
34
+ make test
35
+ ```
36
+ ## ๐Ÿ“š Code Examples
37
+ Configure the C/C++ IntelliSense plugin for VSCode (optional).
38
+ ```
39
+ Clang_format_fallback = Google
40
+ ```
41
+
42
+ IncludePath for VSCode (optional):
43
+ ```
44
+ "includePath": [
45
+ "/opt/homebrew/Cellar/jsoncpp/1.9.6/include/json",
46
+ "${workspaceFolder}/src/cpp",
47
+ "${workspaceFolder}/src"
48
+ ],
49
+ ```
50
+ You can find code examples <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/tests/index.py">here</a>.
51
+
52
+ ## โš–๏ธ MIT License
53
+ This software is licensed under the <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/LICENSE">MIT License</a>. The original author's name, logo, and the original name of the software must be included in all copies or substantial portions of the software.
54
+
55
+ ## ๐Ÿ› ๏ธ Contributing
56
+ Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
57
+
58
+
59
+ ## โญ Release Notes
60
+ Version 0.5.4 - Minimalistic dynamic library
61
+
62
+ We are excited to introduce the Arnelify Broker dynamic library for Python! Please note that this version is raw and still in active development.
63
+
64
+ Change log:
65
+
66
+ * Minimalistic dynamic library
67
+ * NodeJS (Bun) addon
68
+ * FFI Support
69
+
70
+ Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the broker's capabilities, and we welcome your feedback and suggestions.
71
+
72
+ ## ๐Ÿ”— Mentioned
73
+
74
+ * <a href="https://github.com/arnelify/arnelify-pod-cpp">Arnelify POD for C++</a>
75
+ * <a href="https://github.com/arnelify/arnelify-pod-python">Arnelify POD for Python</a>
76
+ * <a href="https://github.com/arnelify/arnelify-pod-node">Arnelify POD for NodeJS</a>
77
+ * <a href="https://github.com/arnelify/arnelify-react-native">Arnelify React Native</a>
@@ -0,0 +1 @@
1
+ from .index import ArnelifyBroker
@@ -0,0 +1,154 @@
1
+ import cffi
2
+ import json
3
+ import platform
4
+
5
+ from concurrent.futures import Future
6
+
7
+ class ArnelifyBroker:
8
+ def __init__(self):
9
+ self.ffi = cffi.FFI()
10
+
11
+ if platform.architecture()[0] != '64bit':
12
+ print("[Arnelify Broker FFI]: CPU platform isn't 64bit.")
13
+ exit(1)
14
+
15
+ if platform.machine() == 'aarch64':
16
+ self.lib = self.ffi.dlopen('./arnelify_broker/bin/arnelify_broker_arm64.so')
17
+
18
+ elif platform.machine() == 'x86_64':
19
+ self.lib = self.ffi.dlopen('./arnelify_broker/bin/arnelify_broker_amd64.so')
20
+ else:
21
+ print("[Arnelify Broker FFI]: CPU platform isn't supported.")
22
+ exit(1)
23
+
24
+ self.ffi.cdef("""
25
+ typedef const char* cSerialized;
26
+ typedef const char* cDeserialized;
27
+
28
+ void broker_create();
29
+ const char* broker_deserialize(cSerialized);
30
+ void broker_destroy();
31
+ void broker_free(cDeserialized);
32
+ const char* broker_get_datetime();
33
+ const char* broker_get_uuid();
34
+ const char* broker_serialize(cDeserialized);
35
+ """)
36
+
37
+ self.actions: dict = {}
38
+ self.req: dict = {}
39
+ self.res: dict = {}
40
+ self.lib.broker_create()
41
+
42
+ def callback(self, message: str, isError: bool) -> None:
43
+ if isError:
44
+ print(message)
45
+ return
46
+
47
+ print(message)
48
+
49
+ def consumer(self, topic: str, onMessage: callable) -> None:
50
+ self.req[topic] = onMessage
51
+
52
+ def deserialize(self, message: str) -> dict:
53
+ cMessage = self.ffi.new("char[]", message.encode('utf-8'))
54
+ cDeserialized = self.lib.broker_deserialize(cMessage)
55
+ deserialized = self.ffi.string(cDeserialized).decode('utf-8')
56
+ self.lib.broker_free(cDeserialized)
57
+ json_: dict = {}
58
+
59
+ try:
60
+ json_ = json.loads(deserialized)
61
+ except json.JSONDecodeError as err:
62
+ self.callback(f"[ArnelifyBroker FFI]: Python error: The Message must be a valid JSON.", True)
63
+ exit(1)
64
+
65
+ return json_
66
+
67
+ def handler(self, topic: str, ctx: dict) -> dict:
68
+ ctx["receivedAt"] = self.getDateTime()
69
+ action: callable = self.actions[topic]
70
+ res: dict = {
71
+ "content": action(ctx),
72
+ "createdAt": ctx["createdAt"],
73
+ "receivedAt": self.getDateTime(),
74
+ "topic": ctx["topic"],
75
+ "uuid": ctx["uuid"],
76
+ }
77
+
78
+ return res
79
+
80
+ def producer(self, topic: str, message: str) -> None:
81
+ onMessage: callable = self.req[topic]
82
+ onMessage(message)
83
+
84
+ def receive(self, res: dict) -> None:
85
+ uuid: str = res["uuid"]
86
+ resolve: callable = self.res[uuid]
87
+ del self.res[uuid]
88
+ resolve(res["content"])
89
+
90
+ def send(self, topic: str, params: dict, producer: callable) -> dict:
91
+ future = Future()
92
+
93
+ uuid: str = self.getUuId()
94
+ def resolve(res: dict) -> None:
95
+ future.set_result(res)
96
+
97
+ self.res[uuid] = resolve
98
+ ctx: dict = {
99
+ "topic": topic,
100
+ "createdAt": self.getDateTime(),
101
+ "params": params,
102
+ "uuid": uuid
103
+ }
104
+
105
+ message: str = self.serialize(ctx)
106
+ producer(message)
107
+ return future.result()
108
+
109
+ def serialize(self, ctx: dict) -> str:
110
+ cCtx: str = json.dumps(ctx)
111
+ cDeserialized = self.ffi.new("char[]", cCtx.encode('utf-8'))
112
+ cSerialized = self.lib.broker_serialize(cDeserialized)
113
+ message: str = self.ffi.string(cSerialized).decode('utf-8')
114
+ self.lib.broker_free(cSerialized)
115
+ return message
116
+
117
+ def call(self, topic: str, params: dict) -> dict:
118
+ def callback(message: str) -> None:
119
+ self.producer(topic + ":req", message)
120
+
121
+ return self.send(topic, params, callback)
122
+
123
+ def getDateTime(self) -> str:
124
+ cDateTime = self.lib.broker_get_datetime()
125
+ datetime: str = self.ffi.string(cDateTime).decode('utf-8')
126
+ self.lib.broker_free(cDateTime)
127
+ return datetime
128
+
129
+ def getUuId(self) -> str:
130
+ cUuId = self.lib.broker_get_uuid()
131
+ uuid: str = self.ffi.string(cUuId).decode('utf-8')
132
+ self.lib.broker_free(cUuId)
133
+ return uuid
134
+
135
+ def setAction(self, topic: str, action: callable) -> None:
136
+ self.actions[topic] = action
137
+
138
+ def subscribe(self, topic: str, action: callable) -> None:
139
+ self.setAction(topic, action)
140
+
141
+ def onResponse(message: str) -> None:
142
+ res: dict = self.deserialize(message)
143
+ self.receive(res)
144
+
145
+ self.consumer(topic + ":res", onResponse)
146
+
147
+ def onRequest(message: str) -> None:
148
+ ctx: dict = self.deserialize(message)
149
+ topic: str = ctx["topic"]
150
+ res: dict = self.handler(topic, ctx)
151
+ serialized: str = self.serialize(res)
152
+ self.producer(topic + ":res", serialized)
153
+
154
+ self.consumer(topic + ":req", onRequest)
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: arnelify-broker
3
+ Version: 0.5.4
4
+ Summary: Minimalistic dynamic library which is a broker written in C and C++.
5
+ Home-page: https://github.com/arnelify/arnelify-broker-python
6
+ Author: Arnelify
7
+ Keywords: arnelify arnelify-broker-python arnelify-broker
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+
14
+ <img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />
15
+
16
+ ![Arnelify Broker for Python](https://img.shields.io/badge/Arnelify%20Broker%20for%20Python-0.5.4-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![Python](https://img.shields.io/badge/Python-14.0.6-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-14.0.6-blue)
17
+
18
+ ## ๐Ÿš€ About
19
+ **Arnelifyยฎ Broker for Python** - is a minimalistic dynamic library which is a message broker written in C and C++.
20
+
21
+ ## ๐Ÿ“‹ Minimal Requirements
22
+ > Important: It's strongly recommended to use in a container that has been built from the gcc v14.2.0 image.
23
+ * CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
24
+ * OS: Debian 11 / MacOS 15 / Windows 10 with <a href="https://learn.microsoft.com/en-us/windows/wsl/install">WSL2</a>.
25
+ * RAM: 4 GB
26
+
27
+ ## ๐Ÿ“ฆ Installation
28
+ Installing via pip:
29
+ ```
30
+ pip install arnelify-broker
31
+ ```
32
+ ## ๐ŸŽ‰ Usage
33
+ Compile library for AMD64:
34
+ ```
35
+ make build_amd64
36
+ ```
37
+ Compile library for ARM64:
38
+ ```
39
+ make build_arm64
40
+ ```
41
+ Compiled test:
42
+ ```
43
+ make test_nuitka
44
+ ```
45
+ Run test:
46
+ ```
47
+ make test
48
+ ```
49
+ ## ๐Ÿ“š Code Examples
50
+ Configure the C/C++ IntelliSense plugin for VSCode (optional).
51
+ ```
52
+ Clang_format_fallback = Google
53
+ ```
54
+
55
+ IncludePath for VSCode (optional):
56
+ ```
57
+ "includePath": [
58
+ "/opt/homebrew/Cellar/jsoncpp/1.9.6/include/json",
59
+ "${workspaceFolder}/src/cpp",
60
+ "${workspaceFolder}/src"
61
+ ],
62
+ ```
63
+ You can find code examples <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/tests/index.py">here</a>.
64
+
65
+ ## โš–๏ธ MIT License
66
+ This software is licensed under the <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/LICENSE">MIT License</a>. The original author's name, logo, and the original name of the software must be included in all copies or substantial portions of the software.
67
+
68
+ ## ๐Ÿ› ๏ธ Contributing
69
+ Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
70
+
71
+
72
+ ## โญ Release Notes
73
+ Version 0.5.4 - Minimalistic dynamic library
74
+
75
+ We are excited to introduce the Arnelify Broker dynamic library for Python! Please note that this version is raw and still in active development.
76
+
77
+ Change log:
78
+
79
+ * Minimalistic dynamic library
80
+ * NodeJS (Bun) addon
81
+ * FFI Support
82
+
83
+ Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the broker's capabilities, and we welcome your feedback and suggestions.
84
+
85
+ ## ๐Ÿ”— Mentioned
86
+
87
+ * <a href="https://github.com/arnelify/arnelify-pod-cpp">Arnelify POD for C++</a>
88
+ * <a href="https://github.com/arnelify/arnelify-pod-python">Arnelify POD for Python</a>
89
+ * <a href="https://github.com/arnelify/arnelify-pod-node">Arnelify POD for NodeJS</a>
90
+ * <a href="https://github.com/arnelify/arnelify-react-native">Arnelify React Native</a>
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ arnelify_broker/__init__.py
5
+ arnelify_broker/index.py
6
+ arnelify_broker.egg-info/PKG-INFO
7
+ arnelify_broker.egg-info/SOURCES.txt
8
+ arnelify_broker.egg-info/dependency_links.txt
9
+ arnelify_broker.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ arnelify_broker
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="arnelify-broker",
5
+ version="0.5.4",
6
+ author="Arnelify",
7
+ description="Minimalistic dynamic library which is a broker written in C and C++.",
8
+ url='https://github.com/arnelify/arnelify-broker-python',
9
+ keywords="arnelify arnelify-broker-python arnelify-broker",
10
+ packages=find_packages(),
11
+ install_requires=[],
12
+ long_description=open("README.md", "r", encoding="utf-8").read(),
13
+ long_description_content_type="text/markdown",
14
+ classifiers=[
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.8",
17
+ "License :: OSI Approved :: MIT License",
18
+ ]
19
+ )