Skip to content

Commit 4ffe0e7

Browse files
committed
TMP Big updates.
1 parent 62d385a commit 4ffe0e7

File tree

29 files changed

+712
-186
lines changed

29 files changed

+712
-186
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212
[lib]
1313
crate-type = ["cdylib"]
14-
name = "_inner"
14+
name = "_natsrpy_rs"
1515

1616
[dependencies]
1717
async-nats = "0.46"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ build-backend = "maturin"
3333
[tool.maturin]
3434
bindings = "pyo3"
3535
features = ["pyo3/extension-module"]
36-
module-name = "natsrpy._inner"
36+
module-name = "natsrpy._natsrpy_rs"
3737
python-source = "python"
3838

3939
[tool.mypy]

python/natsrpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from natsrpy._inner import Message, Nats, Subscription
1+
from natsrpy._natsrpy_rs import Message, Nats, Subscription
22

33
__all__ = [
44
"Message",

python/natsrpy/_inner/message.pyi

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from datetime import timedelta
22
from typing import Any
33

4-
from natsrpy._inner.js import JetStream
5-
from natsrpy._inner.message import Message
4+
from natsrpy._natsrpy_rs.js import JetStream
5+
from natsrpy._natsrpy_rs.message import Message
66

77
class Subscription:
88
def __aiter__(self) -> Subscription: ...

python/natsrpy/_inner/js/__init__.pyi renamed to python/natsrpy/_natsrpy_rs/js/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from natsrpy._inner.js.kv import KeyValue, KVConfig
2-
from natsrpy._inner.js.stream import Stream, StreamConfig
1+
from natsrpy._natsrpy_rs.js.kv import KeyValue, KVConfig
2+
from natsrpy._natsrpy_rs.js.stream import Stream, StreamConfig
33

44
class JetStream:
55
async def publish(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from natsrpy._inner.js.stream import Placement, Republish, Source, StorageType
1+
from natsrpy._natsrpy_rs.js.stream import Placement, Republish, Source, StorageType
22

33
class KVConfig:
44
"""
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,31 @@ class StreamInfo:
228228
class Stream:
229229
async def direct_get(self, sequence: int) -> StreamMessage:
230230
"""
231-
Get direct message from a stream.
231+
Get direct message from the stream.
232232
233-
Please note, that this method will throw an error
234-
in case of stream being configured without `allow_direct=True`.
233+
:param sequence: sequence number of the message to get.
234+
:return: Message.
235+
"""
236+
237+
async def get_info(self) -> StreamInfo:
238+
"""
239+
Get information about the stream.
240+
241+
:return: Stream info.
242+
"""
243+
244+
async def purge(
245+
self,
246+
filter: str | None = None,
247+
sequence: int | None = None,
248+
keep: int | None = None,
249+
) -> int:
250+
"""
251+
Purge current stream.
252+
253+
:param filter: filter of subjects to purge, defaults to None
254+
:param sequence: Message sequence to purge up to (inclusive), defaults to None
255+
:param keep: Message count to keep starting from the end of the stream,
256+
defaults to None
257+
:return: number of messages purged
235258
"""
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from typing import Any
2+
3+
class Message:
4+
"""
5+
Simple NATS message.
6+
7+
Attributes:
8+
subject: subject where message was published
9+
reply: subject where reply should be sent, if any
10+
payload: message payload
11+
headers: dictionary of message headers,
12+
every value can be a simple value or a list.
13+
status: status is used for reply messages to indicate the status of the reply.
14+
It is None for regular messages.
15+
description: message description is used for reply messages to
16+
provide additional information about the status.
17+
length: a length of the message payload in bytes.
18+
"""
19+
20+
subject: str
21+
reply: str | None
22+
payload: bytes
23+
headers: dict[str, Any]
24+
status: int | None
25+
description: str | None
26+
length: int

python/natsrpy/js/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from natsrpy._inner.js import JetStream
1+
from natsrpy._natsrpy_rs.js import JetStream
22
from natsrpy.js.kv import KeyValue, KVConfig
33
from natsrpy.js.stream import (
44
Compression,

0 commit comments

Comments
 (0)