Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/common/src/types/partition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize};
/// - `current_offset`: the current offset of the partition.
/// - `size_bytes`: the size of the partition in bytes.
/// - `messages_count`: the number of messages in the partition.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Partition {
/// Unique identifier of the partition.
pub id: u32,
Expand Down
221 changes: 213 additions & 8 deletions foreign/python/apache_iggy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ __all__ = [
"ConsumerGroupMember",
"IggyClient",
"IggyConsumer",
"IggyExpiry",
"MaxTopicSize",
"Partition",
"PollingStrategy",
"ReceiveMessage",
"SendMessage",
Expand Down Expand Up @@ -449,12 +452,27 @@ class IggyClient:
partitions_count: builtins.int,
compression_algorithm: builtins.str | None = None,
replication_factor: builtins.int | None = None,
message_expiry: datetime.timedelta | None = None,
max_topic_size: builtins.int | None = None,
message_expiry: IggyExpiry | None = None,
max_topic_size: MaxTopicSize | None = None,
) -> collections.abc.Awaitable[None]:
r"""
Creates a new topic with the given parameters.
Returns Ok(()) on successful topic creation or a PyRuntimeError on failure.

Args:
stream: Stream identifier as `str | int`.
name: Topic name as `str`.
partitions_count: Number of partitions as `int`.
compression_algorithm: Compression algorithm as `str | None`.
replication_factor: Replication factor as `int | None`.
message_expiry: Message expiry as `IggyExpiry | None`.
max_topic_size: Maximum topic size as `MaxTopicSize | None`.

Returns:
An awaitable that resolves to `None` when the topic is created.

Raises:
ValueError: If `message_expiry` or `max_topic_size` is out of range.
PyRuntimeError: If another argument is invalid or the request fails.
"""
def get_topic(
self,
Expand Down Expand Up @@ -487,8 +505,8 @@ class IggyClient:
name: builtins.str,
compression_algorithm: builtins.str | None = None,
replication_factor: builtins.int | None = None,
message_expiry: datetime.timedelta | None = None,
max_topic_size: builtins.int | None = None,
message_expiry: IggyExpiry | None = None,
max_topic_size: MaxTopicSize | None = None,
) -> collections.abc.Awaitable[None]:
r"""
Update an existing topic.
Expand All @@ -502,14 +520,15 @@ class IggyClient:
name: New topic name as `str`.
compression_algorithm: Compression algorithm as `str | None`.
replication_factor: Replication factor as `int | None`.
message_expiry: Message expiry as `datetime.timedelta | None`.
max_topic_size: Maximum topic size in bytes as `int | None`.
message_expiry: Message expiry as `IggyExpiry | None`.
max_topic_size: Maximum topic size as `MaxTopicSize | None`.

Returns:
An awaitable that resolves to `None` when the topic is updated.

Raises:
PyRuntimeError: If an argument is invalid or the request fails.
ValueError: If `message_expiry` or `max_topic_size` is out of range.
PyRuntimeError: If another argument is invalid or the request fails.
"""
def delete_topic(
self,
Expand Down Expand Up @@ -818,6 +837,134 @@ class IggyConsumer:
Returns an awaitable that completes when shutdown is signaled or a PyRuntimeError on failure.
"""

class IggyExpiry:
r"""
The expiry of the messages in a topic.
"""
@typing.final
class ServerDefault(IggyExpiry):
r"""
Use the message expiry configured on the server for this topic,
rather than an explicit value set by the client.
"""

__match_args__ = ()
def __new__(cls) -> IggyExpiry.ServerDefault: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...

@typing.final
class ExpireDuration(IggyExpiry):
r"""
Expire messages this long after they are appended to the topic.

`duration` must be greater than zero and less than the maximum
microsecond count a `u64` can hold (about 584,542 years): those two
values are reserved on the wire for `ServerDefault` and `NeverExpire`
respectively, so a `duration` at either boundary raises `ValueError`
when passed to `create_topic`/`update_topic`. A negative `timedelta`
also raises `ValueError`.
"""

__match_args__ = ("duration",)
@property
def duration(self) -> datetime.timedelta: ...
def __new__(cls, duration: datetime.timedelta) -> IggyExpiry.ExpireDuration: ...

@typing.final
class NeverExpire(IggyExpiry):
r"""
Retain messages indefinitely; they never expire.
"""

__match_args__ = ()
def __new__(cls) -> IggyExpiry.NeverExpire: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...

...

class MaxTopicSize:
r"""
The maximum size of a topic.
"""
@typing.final
class ServerDefault(MaxTopicSize):
r"""
Use the maximum topic size configured on the server, rather than an
explicit value set by the client.
"""

__match_args__ = ()
def __new__(cls) -> MaxTopicSize.ServerDefault: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...

@typing.final
class Custom(MaxTopicSize):
r"""
Cap the topic at this many bytes; as the topic approaches this size,
the server deletes the oldest sealed segments to make room for new
messages.

`bytes` must be greater than zero and less than the maximum value of
an unsigned 64-bit integer: those two values are reserved on the wire
for `ServerDefault` and `Unlimited` respectively, so a `Custom` size
at either boundary raises `ValueError` when passed to
`create_topic`/`update_topic`.
"""

__match_args__ = ("bytes",)
@property
def bytes(self) -> builtins.int: ...
def __new__(cls, bytes: builtins.int) -> MaxTopicSize.Custom: ...

@typing.final
class Unlimited(MaxTopicSize):
r"""
Do not cap the topic size; it may grow without bound.
"""

__match_args__ = ()
def __new__(cls) -> MaxTopicSize.Unlimited: ...
def __len__(self) -> builtins.int: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...

...

@typing.final
class Partition:
@property
def id(self) -> builtins.int:
r"""
The unique identifier (numeric) of the partition.
"""
@property
def created_at(self) -> builtins.int:
r"""
The timestamp of the partition creation, in microseconds.
"""
@property
def segments_count(self) -> builtins.int:
r"""
The number of segments in the partition.
"""
@property
def current_offset(self) -> builtins.int:
r"""
The current offset of the partition.
"""
@property
def size(self) -> builtins.int:
r"""
The size of the partition in bytes.
"""
@property
def messages_count(self) -> builtins.int:
r"""
The number of messages in the partition.
"""

class PollingStrategy:
@typing.final
class Offset(PollingStrategy):
Expand Down Expand Up @@ -938,6 +1085,36 @@ class Topic:
r"""
The total number of partitions in the topic.
"""
@property
def created_at(self) -> builtins.int:
r"""
The timestamp when the topic was created, in microseconds.
"""
@property
def size(self) -> builtins.int:
r"""
The total size of the topic in bytes.
"""
@property
def message_expiry(self) -> IggyExpiry:
r"""
The expiry of the messages in the topic.
"""
@property
def compression_algorithm(self) -> builtins.str:
r"""
Compression algorithm for the topic.
"""
@property
def max_topic_size(self) -> MaxTopicSize:
r"""
The maximum size of the topic.
"""
@property
def replication_factor(self) -> builtins.int:
r"""
Replication factor for the topic.
"""

@typing.final
class TopicDetails:
Expand All @@ -962,15 +1139,43 @@ class TopicDetails:
The total number of partitions in the topic.
"""
@property
def created_at(self) -> builtins.int:
r"""
The timestamp when the topic was created, in microseconds.
"""
@property
def size(self) -> builtins.int:
r"""
The total size of the topic in bytes.
"""
@property
def message_expiry(self) -> IggyExpiry:
r"""
The expiry of the messages in the topic.
"""
@property
def compression_algorithm(self) -> builtins.str:
r"""
Compression algorithm for the topic.
"""
@property
def max_topic_size(self) -> MaxTopicSize:
r"""
The maximum size of the topic.
"""
@property
def replication_factor(self) -> builtins.int:
r"""
Replication factor for the topic.
"""
@property
def partitions(self) -> builtins.list[Partition]:
r"""
The collection of partitions in the topic.

Rebuilds the list from scratch on every access; cache the result
rather than reading this repeatedly in a loop.
"""

@typing.final
class UserInfo:
Expand Down
Loading
Loading