Skip to content
Merged
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
4 changes: 2 additions & 2 deletions python/natsrpy/_natsrpy_rs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class Nats:
*,
domain: str | None = None,
api_prefix: str | None = None,
timeout: timedelta | None = None,
ack_timeout: timedelta | None = None,
timeout: float | timedelta | None = None,
ack_timeout: float | timedelta | None = None,
concurrency_limit: int | None = None,
max_ack_inflight: int | None = None,
backpressure_on_inflight: bool | None = None,
Expand Down
20 changes: 10 additions & 10 deletions python/natsrpy/_natsrpy_rs/js/consumers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PullConsumerConfig:
delivery_start_sequence: int | None = None,
delivery_start_time: int | None = None,
ack_policy: AckPolicy | None = None,
ack_wait: timedelta | None = None,
ack_wait: float | timedelta | None = None,
max_deliver: int | None = None,
filter_subject: str | None = None,
filter_subjects: list[str] | None = None,
Expand All @@ -95,12 +95,12 @@ class PullConsumerConfig:
headers_only: bool | None = None,
max_batch: int | None = None,
max_bytes: int | None = None,
max_expires: timedelta | None = None,
inactive_threshold: timedelta | None = None,
max_expires: float | timedelta | None = None,
inactive_threshold: float | timedelta | None = None,
num_replicas: int | None = None,
memory_storage: bool | None = None,
metadata: dict[str, str] | None = None,
backoff: list[timedelta] | None = None,
backoff: list[float | timedelta] | None = None,
priority_policy: PriorityPolicy | None = None,
priority_groups: list[str] | None = None,
pause_until: int | None = None,
Expand Down Expand Up @@ -147,7 +147,7 @@ class PushConsumerConfig:
delivery_start_sequence: int | None = None,
delivery_start_time: int | None = None,
ack_policy: AckPolicy | None = None,
ack_wait: timedelta | None = None,
ack_wait: float | timedelta | None = None,
max_deliver: int | None = None,
filter_subject: str | None = None,
filter_subjects: list[str] | None = None,
Expand All @@ -158,12 +158,12 @@ class PushConsumerConfig:
max_ack_pending: int | None = None,
headers_only: bool | None = None,
flow_control: bool | None = None,
idle_heartbeat: timedelta | None = None,
idle_heartbeat: float | timedelta | None = None,
num_replicas: int | None = None,
memory_storage: bool | None = None,
metadata: dict[str, str] | None = None,
backoff: list[timedelta] | None = None,
inactive_threshold: timedelta | None = None,
backoff: list[float | timedelta] | None = None,
inactive_threshold: float | timedelta | None = None,
pause_until: int | None = None,
) -> Self: ...

Expand All @@ -188,8 +188,8 @@ class PullConsumer:
group: str | None = None,
priority: int | None = None,
max_bytes: int | None = None,
heartbeat: timedelta | None = None,
expires: timedelta | None = None,
heartbeat: float | timedelta | None = None,
expires: float | timedelta | None = None,
min_pending: int | None = None,
min_ack_pending: int | None = None,
timeout: float | timedelta | None = None,
Expand Down
4 changes: 2 additions & 2 deletions python/natsrpy/_natsrpy_rs/js/kv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class KVConfig:
description: str | None = None,
max_value_size: int | None = None,
history: int | None = None,
max_age: float | None = None,
max_age: float | timedelta | None = None,
max_bytes: int | None = None,
storage: StorageType | None = None,
num_replicas: int | None = None,
Expand All @@ -103,7 +103,7 @@ class KVConfig:
mirror_direct: bool | None = None,
compression: bool | None = None,
placement: Placement | None = None,
limit_markers: float | None = None,
limit_markers: float | timedelta | None = None,
) -> Self: ...

@final
Expand Down
6 changes: 3 additions & 3 deletions python/natsrpy/_natsrpy_rs/js/stream.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ class StreamConfig:
discard_new_per_subject: bool | None = None,
retention: RetentionPolicy | None = None,
max_consumers: int | None = None,
max_age: timedelta | None = None,
max_age: float | timedelta | None = None,
max_message_size: int | None = None,
storage: StorageType | None = None,
num_replicas: int | None = None,
no_ack: bool | None = None,
duplicate_window: timedelta | None = None,
duplicate_window: float | timedelta | None = None,
template_owner: str | None = None,
sealed: bool | None = None,
description: str | None = None,
Expand All @@ -193,7 +193,7 @@ class StreamConfig:
persist_mode: PersistenceMode | None = None,
pause_until: int | None = None,
allow_message_ttl: bool | None = None,
subject_delete_marker_ttl: timedelta | None = None,
subject_delete_marker_ttl: float | timedelta | None = None,
allow_atomic_publish: bool | None = None,
allow_message_schedules: bool | None = None,
allow_message_counter: bool | None = None,
Expand Down
21 changes: 13 additions & 8 deletions src/js/consumers/pull/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{collections::HashMap, time::Duration};
use crate::{
exceptions::rust_err::NatsrpyError,
js::consumers::common::{AckPolicy, DeliverPolicy, PriorityPolicy, ReplayPolicy},
utils::py_types::TimeValue,
};

#[pyo3::pyclass(from_py_object, get_all, set_all)]
Expand Down Expand Up @@ -80,7 +81,7 @@ impl PullConsumerConfig {
delivery_start_sequence: Option<u64>,
delivery_start_time: Option<i64>,
ack_policy: Option<AckPolicy>,
ack_wait: Option<Duration>,
ack_wait: Option<TimeValue>,
max_deliver: Option<i64>,
filter_subject: Option<String>,
filter_subjects: Option<Vec<String>>,
Expand All @@ -92,12 +93,12 @@ impl PullConsumerConfig {
headers_only: Option<bool>,
max_batch: Option<i64>,
max_bytes: Option<i64>,
max_expires: Option<Duration>,
inactive_threshold: Option<Duration>,
max_expires: Option<TimeValue>,
inactive_threshold: Option<TimeValue>,
num_replicas: Option<usize>,
memory_storage: Option<bool>,
metadata: Option<HashMap<String, String>>,
backoff: Option<Vec<Duration>>,
backoff: Option<Vec<TimeValue>>,
priority_policy: Option<PriorityPolicy>,
priority_groups: Option<Vec<String>>,
pause_until: Option<i64>,
Expand All @@ -114,7 +115,7 @@ impl PullConsumerConfig {

conf.deliver_policy = deliver_policy.unwrap_or_default();
conf.ack_policy = ack_policy.unwrap_or_default();
conf.ack_wait = ack_wait.unwrap_or_default();
conf.ack_wait = ack_wait.unwrap_or_default().into();
conf.max_deliver = max_deliver.unwrap_or_default();
conf.filter_subject = filter_subject.unwrap_or_default();
conf.filter_subjects = filter_subjects.unwrap_or_default();
Expand All @@ -126,12 +127,16 @@ impl PullConsumerConfig {
conf.headers_only = headers_only.unwrap_or_default();
conf.max_batch = max_batch.unwrap_or_default();
conf.max_bytes = max_bytes.unwrap_or_default();
conf.max_expires = max_expires.unwrap_or_default();
conf.inactive_threshold = inactive_threshold.unwrap_or_default();
conf.max_expires = max_expires.unwrap_or_default().into();
conf.inactive_threshold = inactive_threshold.unwrap_or_default().into();
conf.num_replicas = num_replicas.unwrap_or_default();
conf.memory_storage = memory_storage.unwrap_or_default();
conf.metadata = metadata.unwrap_or_default();
conf.backoff = backoff.unwrap_or_default();
conf.backoff = backoff
.unwrap_or_default()
.into_iter()
.map(Into::into)
.collect();
conf.priority_policy = priority_policy.unwrap_or_default();
conf.priority_groups = priority_groups.unwrap_or_default();

Expand Down
10 changes: 5 additions & 5 deletions src/js/consumers/pull/consumer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{sync::Arc, time::Duration};
use std::sync::Arc;

use futures_util::StreamExt;
use pyo3::{Bound, PyAny, Python};
Expand Down Expand Up @@ -47,8 +47,8 @@ impl PullConsumer {
group: Option<String>,
priority: Option<usize>,
max_bytes: Option<usize>,
heartbeat: Option<Duration>,
expires: Option<Duration>,
heartbeat: Option<TimeValue>,
expires: Option<TimeValue>,
min_pending: Option<usize>,
min_ack_pending: Option<usize>,
timeout: Option<TimeValue>,
Expand All @@ -74,10 +74,10 @@ impl PullConsumer {
fetch_builder = fetch_builder.max_bytes(max_bytes);
}
if let Some(heartbeat) = heartbeat {
fetch_builder = fetch_builder.heartbeat(heartbeat);
fetch_builder = fetch_builder.heartbeat(heartbeat.into());
}
if let Some(expires) = expires {
fetch_builder = fetch_builder.expires(expires);
fetch_builder = fetch_builder.expires(expires.into());
}
if let Some(min_pending) = min_pending {
fetch_builder = fetch_builder.min_pending(min_pending);
Expand Down
21 changes: 13 additions & 8 deletions src/js/consumers/push/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{collections::HashMap, time::Duration};
use crate::{
exceptions::rust_err::NatsrpyError,
js::consumers::common::{AckPolicy, DeliverPolicy, ReplayPolicy},
utils::py_types::TimeValue,
};

#[pyo3::pyclass(from_py_object, get_all, set_all)]
Expand Down Expand Up @@ -81,7 +82,7 @@ impl PushConsumerConfig {
delivery_start_sequence: Option<u64>,
delivery_start_time: Option<i64>,
ack_policy: Option<AckPolicy>,
ack_wait: Option<Duration>,
ack_wait: Option<TimeValue>,
max_deliver: Option<i64>,
filter_subject: Option<String>,
filter_subjects: Option<Vec<String>>,
Expand All @@ -92,12 +93,12 @@ impl PushConsumerConfig {
max_ack_pending: Option<i64>,
headers_only: Option<bool>,
flow_control: Option<bool>,
idle_heartbeat: Option<Duration>,
idle_heartbeat: Option<TimeValue>,
num_replicas: Option<usize>,
memory_storage: Option<bool>,
metadata: Option<HashMap<String, String>>,
backoff: Option<Vec<Duration>>,
inactive_threshold: Option<Duration>,
backoff: Option<Vec<TimeValue>>,
inactive_threshold: Option<TimeValue>,
pause_until: Option<i64>,
) -> Self {
Self {
Expand All @@ -112,7 +113,7 @@ impl PushConsumerConfig {

deliver_policy: deliver_policy.unwrap_or_default(),
ack_policy: ack_policy.unwrap_or_default(),
ack_wait: ack_wait.unwrap_or_default(),
ack_wait: ack_wait.unwrap_or_default().into(),
max_deliver: max_deliver.unwrap_or_default(),
filter_subject: filter_subject.unwrap_or_default(),
filter_subjects: filter_subjects.unwrap_or_default(),
Expand All @@ -123,12 +124,16 @@ impl PushConsumerConfig {
max_ack_pending: max_ack_pending.unwrap_or_default(),
headers_only: headers_only.unwrap_or_default(),
flow_control: flow_control.unwrap_or_default(),
idle_heartbeat: idle_heartbeat.unwrap_or_default(),
idle_heartbeat: idle_heartbeat.unwrap_or_default().into(),
num_replicas: num_replicas.unwrap_or_default(),
memory_storage: memory_storage.unwrap_or_default(),
metadata: metadata.unwrap_or_default(),
backoff: backoff.unwrap_or_default(),
inactive_threshold: inactive_threshold.unwrap_or_default(),
backoff: backoff
.unwrap_or_default()
.into_iter()
.map(Into::into)
.collect(),
inactive_threshold: inactive_threshold.unwrap_or_default().into(),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/js/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ impl KVConfig {
limit_markers=None,
))]
#[must_use]
pub const fn __new__(
pub fn __new__(
bucket: String,
description: Option<String>,
max_value_size: Option<i32>,
history: Option<i64>,
max_age: Option<Duration>,
max_age: Option<TimeValue>,
max_bytes: Option<i64>,
storage: Option<js::stream::StorageType>,
num_replicas: Option<usize>,
Expand All @@ -76,14 +76,14 @@ impl KVConfig {
mirror_direct: Option<bool>,
compression: Option<bool>,
placement: Option<js::stream::Placement>,
limit_markers: Option<Duration>,
limit_markers: Option<TimeValue>,
) -> Self {
Self {
bucket,
description,
max_value_size,
history,
max_age,
max_age: max_age.map(Into::into),
max_bytes,
storage,
num_replicas,
Expand All @@ -93,7 +93,7 @@ impl KVConfig {
mirror_direct,
compression,
placement,
limit_markers,
limit_markers: limit_markers.map(Into::into),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/js/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ pub struct ConsumerLimits {
impl ConsumerLimits {
#[new]
#[must_use]
pub const fn __new__(inactive_threshold: Duration, max_ack_pending: i64) -> Self {
pub fn __new__(inactive_threshold: TimeValue, max_ack_pending: i64) -> Self {
Self {
inactive_threshold,
inactive_threshold: inactive_threshold.into(),
max_ack_pending,
}
}
Expand Down Expand Up @@ -595,12 +595,12 @@ impl StreamConfig {
discard_new_per_subject: Option<bool>,
retention: Option<RetentionPolicy>,
max_consumers: Option<i32>,
max_age: Option<Duration>,
max_age: Option<TimeValue>,
max_message_size: Option<i32>,
storage: Option<StorageType>,
num_replicas: Option<usize>,
no_ack: Option<bool>,
duplicate_window: Option<Duration>,
duplicate_window: Option<TimeValue>,
template_owner: Option<String>,
sealed: Option<bool>,
description: Option<String>,
Expand All @@ -621,7 +621,7 @@ impl StreamConfig {
persist_mode: Option<PersistenceMode>,
pause_until: Option<i64>,
allow_message_ttl: Option<bool>,
subject_delete_marker_ttl: Option<Duration>,
subject_delete_marker_ttl: Option<TimeValue>,
allow_atomic_publish: Option<bool>,
allow_message_schedules: Option<bool>,
allow_message_counter: Option<bool>,
Expand All @@ -640,21 +640,21 @@ impl StreamConfig {
placement,
persist_mode,
pause_until,
subject_delete_marker_ttl,

subject_delete_marker_ttl: subject_delete_marker_ttl.map(Into::into),
max_bytes: max_bytes.unwrap_or_default(),
max_messages: max_messages.unwrap_or_default(),
max_messages_per_subject: max_messages_per_subject.unwrap_or_default(),
discard: discard.unwrap_or_default(),
discard_new_per_subject: discard_new_per_subject.unwrap_or_default(),
retention: retention.unwrap_or_default(),
max_consumers: max_consumers.unwrap_or_default(),
max_age: max_age.unwrap_or_default(),
max_age: max_age.unwrap_or_default().into(),
max_message_size: max_message_size.unwrap_or_default(),
storage: storage.unwrap_or_default(),
num_replicas: num_replicas.unwrap_or_default(),
no_ack: no_ack.unwrap_or_default(),
duplicate_window: duplicate_window.unwrap_or_default(),
duplicate_window: duplicate_window.unwrap_or_default().into(),
template_owner: template_owner.unwrap_or_default(),
sealed: sealed.unwrap_or_default(),
allow_rollup: allow_rollup.unwrap_or_default(),
Expand Down
Loading
Loading