- 
                Notifications
    
You must be signed in to change notification settings  - Fork 232
 
Description
Proposed change
nats.py's nats.js.api.KeyValueConfig as long as nats.js.api.StreamConfig do not expose the JetStream's "limit marker" option required to enable per-key TTL with delete markers. While KeyValueConfig's ttl option sets the expiration for values, without limit_marker_ttl the client cannot receive PURGE events when keys expire.
As a workaround, it is currently possible to declare a kv externally, e.g. using the nats-cli: nats kv add mybucket --ttl=60s --marker-ttl=60s.
Proposed solution: add new field limit_marker_ttl to nats.js.api.KeyValueConfig, then add the same field to nats.js.api.StreamConfig and check if it's handled correctly in nats.js.manager.JetStreamManager.add_stream.
Context:
- nats-py version: 2.11.0
 - nats-server version: 2.11.8
 
References:
- Marker TTLs in Streams: https://docs.nats.io/release-notes/whats_new/whats_new_211?ask=SubjectDeleteMarkerTTL#streams
 - Receiving watch events for TTL'd objects: Receive watch events for TTL'd KV objects nats-server#3268
 KeyValueConfigwith support ofLimitMarkerTTLin Go SDK: https://pkg.go.dev/github.com/nats-io/nats.go/jetstream#KeyValueConfig
Use case
I need to watch not only PUT events in a KV bucket, but also PURGE events when keys are automatically deleted according to the bucket's TTL policy. Without limit_marker_ttl, I cannot achieve feature parity with other SDKs and cannot reliably react to key expirations.
Contribution
No response