File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,12 @@ class StreamConfig(Base):
311311 # Allow scheduled/delayed messages. Introduced in nats-server 2.12.0.
312312 allow_msg_schedules : Optional [bool ] = None
313313
314+ # Allow atomic batch publishing. Introduced in nats-server 2.12.0.
315+ allow_atomic : Optional [bool ] = None
316+
317+ # Allow batched publishing. Introduced in nats-server 2.12.0.
318+ allow_batched : Optional [bool ] = None
319+
314320 # Metadata are user defined string key/value pairs.
315321 metadata : Optional [Dict [str , str ]] = None
316322
Original file line number Diff line number Diff line change @@ -4649,6 +4649,42 @@ async def test_stream_allow_msg_schedules(self):
46494649
46504650 await nc .close ()
46514651
4652+ @async_test
4653+ async def test_stream_allow_atomic (self ):
4654+ nc = await nats .connect ()
4655+
4656+ server_version = nc .connected_server_version
4657+ if server_version .major == 2 and server_version .minor < 12 :
4658+ pytest .skip ("allow_atomic requires nats-server v2.12.0 or later" )
4659+
4660+ js = nc .jetstream ()
4661+ await js .add_stream (
4662+ name = "ATOMIC" ,
4663+ subjects = ["test" ],
4664+ allow_atomic = True ,
4665+ )
4666+ sinfo = await js .stream_info ("ATOMIC" )
4667+ assert sinfo .config .allow_atomic is True
4668+
4669+ # Test that it can be set to False
4670+ await js .add_stream (
4671+ name = "NOATOMIC" ,
4672+ subjects = ["foo" ],
4673+ allow_atomic = False ,
4674+ )
4675+ sinfo = await js .stream_info ("NOATOMIC" )
4676+ assert sinfo .config .allow_atomic is not True
4677+
4678+ # Test that it defaults to falsy when not set
4679+ await js .add_stream (
4680+ name = "DEFAULT2" ,
4681+ subjects = ["baz" ],
4682+ )
4683+ sinfo = await js .stream_info ("DEFAULT2" )
4684+ assert sinfo .config .allow_atomic is not True
4685+
4686+ await nc .close ()
4687+
46524688 @async_test
46534689 async def test_fetch_pull_subscribe_bind (self ):
46544690 nc = NATS ()
You can’t perform that action at this time.
0 commit comments