Skip to content

Commit

Permalink
Move subject_delete_marker_ttl to a time.Duration
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Jan 27, 2025
1 parent 5623676 commit 9bc2c42
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api/streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ type StreamConfig struct {
// Enables placing markers in the stream for certain message delete operations
SubjectDeleteMarkers bool `json:"subject_delete_markers,omitempty" yaml:"subject_delete_markers"`
// When placing a marker, how long should it be valid, defaults to 15m
SubjectDeleteMarkerTTL string `json:"subject_delete_marker_ttl,omitempty" yaml:"subject_delete_marker_ttl"`
SubjectDeleteMarkerTTL time.Duration `json:"subject_delete_marker_ttl,omitempty" yaml:"subject_delete_marker_ttl"`
// The following defaults will apply to consumers when created against
// this stream, unless overridden manually. They also represent the maximum values that
// these properties may have
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/klauspost/compress v1.17.11
github.com/nats-io/jwt/v2 v2.7.3
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250122133427-2352ad9fd254
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250126014539-f2eb5650d200
github.com/nats-io/nats.go v1.38.0
github.com/nats-io/nkeys v0.4.9
github.com/nats-io/nuid v1.0.1
Expand All @@ -34,6 +34,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/time v0.9.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE=
github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250122133427-2352ad9fd254 h1:3slXeEjjTNhhndJ7FEFqSx//GxSGG22C8IjsER7YIM0=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250122133427-2352ad9fd254/go.mod h1:NLseHFkD5ZPPkHVYn4JEG8LguxveaOXJPiIfswZugHg=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250126014539-f2eb5650d200 h1:JTZQwrehqUHpEO+DRjm0734B4a0porO1Cb5ACT0nSJY=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250126014539-f2eb5650d200/go.mod h1:NLseHFkD5ZPPkHVYn4JEG8LguxveaOXJPiIfswZugHg=
github.com/nats-io/nats.go v1.38.0 h1:A7P+g7Wjp4/NWqDOOP/K6hfhr54DvdDQUznt5JFg9XA=
github.com/nats-io/nats.go v1.38.0/go.mod h1:IGUM++TwokGnXPs82/wCuiHS02/aKrdYUQkU8If6yjw=
github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0=
Expand All @@ -58,6 +60,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
Expand Down
3 changes: 2 additions & 1 deletion schema_source/jetstream/api/v1/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,8 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"$ref": "#/definitions/golang_duration_nanos",
"minimum": 0
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion schemas/jetstream/api/v1/consumer_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
}
},
"priority_policy": {
"description": "The policy the consumer is set to",
"description": "The priority policy the consumer is set to",
"type": "string",
"enum": [
"none",
Expand Down
2 changes: 1 addition & 1 deletion schemas/jetstream/api/v1/consumer_create_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
}
},
"priority_policy": {
"description": "The policy the consumer is set to",
"description": "The priority policy the consumer is set to",
"type": "string",
"enum": [
"none",
Expand Down
2 changes: 1 addition & 1 deletion schemas/jetstream/api/v1/consumer_create_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
}
},
"priority_policy": {
"description": "The policy the consumer is set to",
"description": "The priority policy the consumer is set to",
"type": "string",
"enum": [
"none",
Expand Down
2 changes: 1 addition & 1 deletion schemas/jetstream/api/v1/consumer_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
}
},
"priority_policy": {
"description": "The policy the consumer is set to",
"description": "The priority policy the consumer is set to",
"type": "string",
"enum": [
"none",
Expand Down
2 changes: 1 addition & 1 deletion schemas/jetstream/api/v1/consumer_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
}
},
"priority_policy": {
"description": "The policy the consumer is set to",
"description": "The priority policy the consumer is set to",
"type": "string",
"enum": [
"none",
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_create_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_create_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_restore_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_snapshot_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_template_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_template_create_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_template_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_update_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion schemas/jetstream/api/v1/stream_update_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@
},
"subject_delete_marker_ttl": {
"description": "When placing a marker, how long should it be valid, defaults to 15m",
"type": "string"
"minimum": 0,
"$comment": "nanoseconds depicting a duration in time, signed 64 bit integer",
"type": "integer",
"maximum": 9223372036854775807
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ func AllowSubjectDeleteMarkers() StreamOption {
}
}

func SubjectDeleteMarkerTTL(d string) StreamOption {
func SubjectDeleteMarkerTTL(d time.Duration) StreamOption {
return func(o *api.StreamConfig) error {
err := AllowSubjectDeleteMarkers()(o)
if err != nil {
Expand Down Expand Up @@ -1146,5 +1146,5 @@ func (s *Stream) Compression() api.Compression { return s.cfg.Compre
func (s *Stream) FirstSequence() uint64 { return s.cfg.FirstSeq }
func (s *Stream) AllowMsgTTL() bool { return s.cfg.AllowMsgTTL }
func (s *Stream) SubjectDeleteMarkers() bool { return s.cfg.SubjectDeleteMarkers }
func (s *Stream) SubjectDeleteMarkerTTL() string { return s.cfg.SubjectDeleteMarkerTTL }
func (s *Stream) SubjectDeleteMarkerTTL() time.Duration { return s.cfg.SubjectDeleteMarkerTTL }
func (s *Stream) ConsumerLimits() api.StreamConsumerLimits { return s.cfg.ConsumerLimits }

0 comments on commit 9bc2c42

Please sign in to comment.