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
3 changes: 3 additions & 0 deletions nats/src/nats/js/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class StreamConfig(Base):
# Allow compressing messages.
compression: Optional[StoreCompression] = None

# Allow scheduled/delayed messages. Introduced in nats-server 2.12.0.
allow_msg_schedules: Optional[bool] = None

# Metadata are user defined string key/value pairs.
metadata: Optional[Dict[str, str]] = None

Expand Down
36 changes: 36 additions & 0 deletions nats/tests/test_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -4533,6 +4533,42 @@ async def test_stream_consumer_metadata(self):

await nc.close()

@async_test
async def test_stream_allow_msg_schedules(self):
nc = await nats.connect()

server_version = nc.connected_server_version
if server_version.major == 2 and server_version.minor < 12:
pytest.skip("allow_msg_schedules requires nats-server v2.12.0 or later")

js = nc.jetstream()
await js.add_stream(
name="SCHEDULES",
subjects=["test"],
allow_msg_schedules=True,
)
sinfo = await js.stream_info("SCHEDULES")
assert sinfo.config.allow_msg_schedules is True

# Test that it can be set to False
await js.add_stream(
name="NOSCHEDULES",
subjects=["foo"],
allow_msg_schedules=False,
)
sinfo = await js.stream_info("NOSCHEDULES")
assert sinfo.config.allow_msg_schedules is not True

# Test that it defaults to falsy when not set
await js.add_stream(
name="DEFAULT",
subjects=["bar"],
)
sinfo = await js.stream_info("DEFAULT")
assert sinfo.config.allow_msg_schedules is not True

await nc.close()

@async_test
async def test_fetch_pull_subscribe_bind(self):
nc = NATS()
Expand Down
Loading