Skip to content

Commit 7076b61

Browse files
authored
Merge pull request #95 from nats-io/stream_compression
Support stream compression
2 parents d412f4e + 2f82daf commit 7076b61

File tree

8 files changed

+92
-37
lines changed

8 files changed

+92
-37
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ resource "jetstream_stream" "ORDERS" {
130130
* `ack` - (optional) If the Stream should support confirming receiving messages via acknowledgements (bool)
131131
* `max_age` - (optional) The maximum oldest message that can be kept in the stream, duration specified in seconds (number)
132132
* `max_bytes` - (optional) The maximum size of all messages that can be kept in the stream (number)
133+
* `compression` - (optional) Enable stream compression by setting the value to `s2`
133134
* `max_consumers` - (optional) Number of consumers this stream allows (number)
134135
* `max_msg_size` - (optional) The maximum individual message size that the stream will accept (number)
135136
* `max_msgs` - (optional) The maximum amount of messages that can be kept in the stream (number)

docs/resources/jetstream_stream.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Above the `ORDERS_ARCHIVE` stream is a mirror of `ORDERS`, valid options for spe
4545
* `max_age` - (optional) The maximum oldest message that can be kept in the stream, duration specified in seconds (number)
4646
* `max_bytes` - (optional) The maximum size of all messages that can be kept in the stream (number)
4747
* `max_consumers` - (optional) Number of consumers this stream allows (number)
48+
* `compression` - (optional) Enable stream compression by setting the value to `s2`
4849
* `max_msg_size` - (optional) The maximum individual message size that the stream will accept (number)
4950
* `max_msgs` - (optional) The maximum amount of messages that can be kept in the stream (number)
5051
* `max_msgs_per_subject` (optional) The maximum amount of messages that can be kept in the stream on a per-subject basis (number)

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ go 1.20
55
require (
66
github.com/google/go-cmp v0.5.9
77
github.com/hashicorp/terraform-plugin-sdk v1.17.2
8-
github.com/nats-io/jsm.go v0.0.36-0.20230814153802-490edca64ad9
9-
github.com/nats-io/jwt/v2 v2.4.1
10-
github.com/nats-io/nats-server/v2 v2.9.22-0.20230812221748-b839c53abcec
11-
github.com/nats-io/nats.go v1.28.0
8+
github.com/nats-io/jsm.go v0.0.36-0.20230919135355-c609acc39d33
9+
github.com/nats-io/jwt/v2 v2.5.2
10+
github.com/nats-io/nats-server/v2 v2.9.23-0.20230918205325-3dc06278119c
11+
github.com/nats-io/nats.go v1.29.0
1212
github.com/xeipuuv/gojsonschema v1.2.0
1313
)
1414

@@ -21,7 +21,7 @@ require (
2121
github.com/Masterminds/semver v1.5.0 // indirect
2222
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
2323
github.com/agext/levenshtein v1.2.2 // indirect
24-
github.com/antonmedv/expr v1.13.0 // indirect
24+
github.com/antonmedv/expr v1.15.2 // indirect
2525
github.com/apparentlymart/go-cidr v1.1.0 // indirect
2626
github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect
2727
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
@@ -59,7 +59,7 @@ require (
5959
github.com/huandu/xstrings v1.3.2 // indirect
6060
github.com/imdario/mergo v0.3.12 // indirect
6161
github.com/jmespath/go-jmespath v0.4.0 // indirect
62-
github.com/klauspost/compress v1.16.7 // indirect
62+
github.com/klauspost/compress v1.17.0 // indirect
6363
github.com/mattn/go-colorable v0.1.1 // indirect
6464
github.com/mattn/go-isatty v0.0.5 // indirect
6565
github.com/minio/highwayhash v1.0.2 // indirect
@@ -71,7 +71,7 @@ require (
7171
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
7272
github.com/mitchellh/mapstructure v1.1.2 // indirect
7373
github.com/mitchellh/reflectwalk v1.0.1 // indirect
74-
github.com/nats-io/nkeys v0.4.4 // indirect
74+
github.com/nats-io/nkeys v0.4.5 // indirect
7575
github.com/nats-io/nuid v1.0.1 // indirect
7676
github.com/oklog/run v1.0.0 // indirect
7777
github.com/posener/complete v1.2.1 // indirect
@@ -84,11 +84,11 @@ require (
8484
github.com/zclconf/go-cty v1.10.0 // indirect
8585
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
8686
go.opencensus.io v0.23.0 // indirect
87-
golang.org/x/crypto v0.12.0 // indirect
88-
golang.org/x/net v0.14.0 // indirect
87+
golang.org/x/crypto v0.13.0 // indirect
88+
golang.org/x/net v0.15.0 // indirect
8989
golang.org/x/oauth2 v0.1.0 // indirect
90-
golang.org/x/sys v0.11.0 // indirect
91-
golang.org/x/text v0.12.0 // indirect
90+
golang.org/x/sys v0.12.0 // indirect
91+
golang.org/x/text v0.13.0 // indirect
9292
golang.org/x/time v0.3.0 // indirect
9393
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
9494
google.golang.org/api v0.100.0 // indirect

go.sum

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/g
200200
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE=
201201
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
202202
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
203-
github.com/antonmedv/expr v1.13.0 h1:8YrTtlCzlOtXw+hpeCLDLL2uo0C0k6jmYpYTGws5c5w=
204-
github.com/antonmedv/expr v1.13.0/go.mod h1:FPC8iWArxls7axbVLsW+kpg1mz29A1b2M6jt+hZfDkU=
203+
github.com/antonmedv/expr v1.15.2 h1:afFXpDWIC2n3bF+kTZE1JvFo+c34uaM3sTqh8z0xfdU=
204+
github.com/antonmedv/expr v1.15.2/go.mod h1:0E/6TxnOlRNp81GMzX9QfDPAmHo2Phg00y4JUv1ihsE=
205205
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
206206
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
207207
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
@@ -449,8 +449,8 @@ github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZsc
449449
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
450450
github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
451451
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
452-
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
453-
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
452+
github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM=
453+
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
454454
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
455455
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
456456
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
@@ -494,16 +494,16 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
494494
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
495495
github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE=
496496
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
497-
github.com/nats-io/jsm.go v0.0.36-0.20230814153802-490edca64ad9 h1:iovWg573DqMS60WskqkrsjMyhPoTSDKStjs8dA+FYP8=
498-
github.com/nats-io/jsm.go v0.0.36-0.20230814153802-490edca64ad9/go.mod h1:MyB1zGGllqlJdUXUJBKPI93fajK7LknUVQebNEMmod4=
499-
github.com/nats-io/jwt/v2 v2.4.1 h1:Y35W1dgbbz2SQUYDPCaclXcuqleVmpbRa7646Jf2EX4=
500-
github.com/nats-io/jwt/v2 v2.4.1/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI=
501-
github.com/nats-io/nats-server/v2 v2.9.22-0.20230812221748-b839c53abcec h1:WlIeTCfqbb94PZXcpjLnikseyGQv2lLMNIew0eF1esw=
502-
github.com/nats-io/nats-server/v2 v2.9.22-0.20230812221748-b839c53abcec/go.mod h1:ozqMZc2vTHcNcblOiXMWIXkf8+0lDGAi5wQcG+O1mHU=
503-
github.com/nats-io/nats.go v1.28.0 h1:Th4G6zdsz2d0OqXdfzKLClo6bOfoI/b1kInhRtFIy5c=
504-
github.com/nats-io/nats.go v1.28.0/go.mod h1:XpbWUlOElGwTYbMR7imivs7jJj9GtK7ypv321Wp6pjc=
505-
github.com/nats-io/nkeys v0.4.4 h1:xvBJ8d69TznjcQl9t6//Q5xXuVhyYiSos6RPtvQNTwA=
506-
github.com/nats-io/nkeys v0.4.4/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
497+
github.com/nats-io/jsm.go v0.0.36-0.20230919135355-c609acc39d33 h1:Ixd98B8Pq0dUxi++ENmZFxDeTBsfG3lbSkaaiDVV6So=
498+
github.com/nats-io/jsm.go v0.0.36-0.20230919135355-c609acc39d33/go.mod h1:/lp3tYWC8DYa7XLxRICA57igfAYquPXEcZvCQ5L3zSk=
499+
github.com/nats-io/jwt/v2 v2.5.2 h1:DhGH+nKt+wIkDxM6qnVSKjokq5t59AZV5HRcFW0zJwU=
500+
github.com/nats-io/jwt/v2 v2.5.2/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI=
501+
github.com/nats-io/nats-server/v2 v2.9.23-0.20230918205325-3dc06278119c h1:yHb64vNSinDkZbBQRpoKR4cfTuAR57uJ9qW93oQCdbM=
502+
github.com/nats-io/nats-server/v2 v2.9.23-0.20230918205325-3dc06278119c/go.mod h1:3PMvMSu2cuK0J9YInRLWdFpFsswKKGUS77zVSAudRto=
503+
github.com/nats-io/nats.go v1.29.0 h1:dSXZ+SZeGyTdHVYeXimeq12FsIpb9dM8CJ2IZFiHcyE=
504+
github.com/nats-io/nats.go v1.29.0/go.mod h1:XpbWUlOElGwTYbMR7imivs7jJj9GtK7ypv321Wp6pjc=
505+
github.com/nats-io/nkeys v0.4.5 h1:Zdz2BUlFm4fJlierwvGK+yl20IAKUm7eV6AAZXEhkPk=
506+
github.com/nats-io/nkeys v0.4.5/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
507507
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
508508
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
509509
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
@@ -532,16 +532,13 @@ github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
532532
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
533533
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
534534
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
535-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
536535
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
537536
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
538537
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
539538
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
540539
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
541540
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
542-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
543-
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
544-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
541+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
545542
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
546543
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
547544
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
@@ -593,8 +590,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
593590
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
594591
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
595592
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
596-
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
597-
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
593+
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
594+
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
598595
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
599596
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
600597
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -605,6 +602,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
605602
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
606603
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
607604
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
605+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
608606
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
609607
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
610608
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -682,8 +680,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
682680
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
683681
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
684682
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
685-
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
686-
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
683+
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
684+
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
687685
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
688686
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
689687
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -793,8 +791,8 @@ golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBc
793791
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
794792
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
795793
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
796-
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
797-
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
794+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
795+
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
798796
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
799797
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
800798
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -808,8 +806,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
808806
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
809807
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
810808
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
811-
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
812-
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
809+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
810+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
813811
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
814812
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
815813
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

jetstream/resource_jetstream_stream.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ func resourceStream() *schema.Resource {
168168
Optional: true,
169169
ValidateFunc: validateRetentionTypeString(),
170170
},
171+
"compression": {
172+
Type: schema.TypeString,
173+
Description: "Optional compression algorithm used for the Stream",
174+
Default: "none",
175+
Optional: true,
176+
ValidateFunc: validateCompressionTypeString(),
177+
},
171178
"max_consumers": {
172179
Type: schema.TypeInt,
173180
Description: "Number of consumers this stream allows",
@@ -329,6 +336,7 @@ func resourceStreamRead(d *schema.ResourceData, m any) error {
329336
d.Set("allow_rollup_hdrs", str.RollupAllowed())
330337
d.Set("allow_direct", str.DirectAllowed())
331338
d.Set("discard_new_per_subject", str.DiscardNewPerSubject())
339+
d.Set("compression", str.Compression())
332340

333341
if str.MaxAge() == -1 || str.MaxAge() == 0 {
334342
d.Set("max_age", "-1")

jetstream/resource_jetstream_stream_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resource "jetstream_stream" "test" {
1818
name = "TEST"
1919
subjects = ["TEST.*"]
2020
description = "testing stream"
21+
compression = "s2"
2122
metadata = {
2223
foo = "bar"
2324
}
@@ -114,15 +115,18 @@ func TestResourceStream(t *testing.T) {
114115
testStreamExist(t, mgr, "TEST"),
115116
testStreamHasSubjects(t, mgr, "TEST", []string{"TEST.*"}),
116117
testStreamHasMetadata(t, mgr, "TEST", map[string]string{"foo": "bar"}),
118+
testStreamIsCompressed(t, mgr, "TEST"),
117119
resource.TestCheckResourceAttr("jetstream_stream.test", "max_msgs", "-1"),
118120
resource.TestCheckResourceAttr("jetstream_stream.test", "description", "testing stream"),
119121
resource.TestCheckResourceAttr("jetstream_stream.test", "deny_delete", "false"),
122+
resource.TestCheckResourceAttr("jetstream_stream.test", "compression", "s2"),
120123
),
121124
},
122125
{
123126
Config: fmt.Sprintf(testStreamConfigOtherSubjects, nc.ConnectedUrl()),
124127
Check: resource.ComposeTestCheckFunc(
125128
testStreamExist(t, mgr, "TEST"),
129+
testStreamIsUnCompressed(t, mgr, "TEST"),
126130
testStreamHasSubjects(t, mgr, "TEST", []string{"OTHER.*"}),
127131
resource.TestCheckResourceAttr("jetstream_stream.test", "max_msgs", "10"),
128132
resource.TestCheckResourceAttr("jetstream_stream.test", "max_msgs_per_subject", "2"),

jetstream/util.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ func parseConsumerID(id string) (stream string, consumer string, err error) {
5858
return matches[1], matches[2], nil
5959
}
6060

61+
func validateCompressionTypeString() schema.SchemaValidateFunc {
62+
return validation.StringInSlice([]string{"none", "s2"}, false)
63+
}
64+
6165
func validateRetentionTypeString() schema.SchemaValidateFunc {
6266
return validation.StringInSlice([]string{"limits", "interest", "workqueue"}, false)
6367
}
@@ -204,6 +208,14 @@ func streamConfigFromResourceData(d *schema.ResourceData) (cfg api.StreamConfig,
204208
stream.MaxMsgsPer = int64(limit.(int))
205209
}
206210

211+
compression := d.Get("compression")
212+
switch compression {
213+
case "none":
214+
stream.Compression = api.NoCompression
215+
case "s2":
216+
stream.Compression = api.S2Compression
217+
}
218+
207219
mirror, ok := d.GetOk("mirror")
208220
if ok {
209221
sources, err := streamSourceFromResourceData(mirror)

jetstream/util_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
99
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1010
"github.com/nats-io/jsm.go"
11+
"github.com/nats-io/jsm.go/api"
1112
)
1213

1314
func testStreamHasMetadata(t *testing.T, mgr *jsm.Manager, stream string, metadata map[string]string) resource.TestCheckFunc {
@@ -105,6 +106,36 @@ func testStreamIsMirrorOf(t *testing.T, mgr *jsm.Manager, stream string, mirror
105106
}
106107
}
107108

109+
func testStreamIsCompressed(t *testing.T, mgr *jsm.Manager, stream string) resource.TestCheckFunc {
110+
return func(s *terraform.State) error {
111+
str, err := mgr.LoadStream(stream)
112+
if err != nil {
113+
return err
114+
}
115+
116+
if str.Compression() != api.S2Compression {
117+
return fmt.Errorf("stream is uncompressed")
118+
}
119+
120+
return nil
121+
}
122+
}
123+
124+
func testStreamIsUnCompressed(t *testing.T, mgr *jsm.Manager, stream string) resource.TestCheckFunc {
125+
return func(s *terraform.State) error {
126+
str, err := mgr.LoadStream(stream)
127+
if err != nil {
128+
return err
129+
}
130+
131+
if str.Compression() != api.NoCompression {
132+
return fmt.Errorf("stream is compressed")
133+
}
134+
135+
return nil
136+
}
137+
}
138+
108139
func testStreamExist(t *testing.T, mgr *jsm.Manager, stream string) resource.TestCheckFunc {
109140
return func(s *terraform.State) error {
110141
known, err := mgr.IsKnownStream(stream)

0 commit comments

Comments
 (0)