Skip to content

Commit

Permalink
Merge pull request #955 from nats-io/obj-maxbytes
Browse files Browse the repository at this point in the history
Add a MaxBytes configuration option to the Object Store
  • Loading branch information
ColinSullivan1 committed Apr 12, 2022
2 parents 1714729 + eb82aed commit c75dfd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions object.go
Expand Up @@ -136,6 +136,7 @@ type ObjectStoreConfig struct {
Bucket string
Description string
TTL time.Duration
MaxBytes int64
Storage StorageType
Replicas int
Placement *Placement
Expand Down Expand Up @@ -244,6 +245,7 @@ func (js *js) CreateObjectStore(cfg *ObjectStoreConfig) (ObjectStore, error) {
Description: cfg.Description,
Subjects: []string{chunks, meta},
MaxAge: cfg.TTL,
MaxBytes: cfg.MaxBytes,
Storage: cfg.Storage,
Replicas: cfg.Replicas,
Placement: cfg.Placement,
Expand Down
19 changes: 19 additions & 0 deletions test/object_test.go
Expand Up @@ -588,3 +588,22 @@ func TestObjectList(t *testing.T) {
t.Fatalf("Expected %+v but got %+v", expected, omap)
}
}

func TestObjectMaxBytes(t *testing.T) {
s := RunBasicJetStreamServer()
defer shutdownJSServerAndRemoveStorage(t, s)

nc, js := jsClient(t, s)
defer nc.Close()

obs, err := js.CreateObjectStore(&nats.ObjectStoreConfig{Bucket: "OBJS", MaxBytes: 1024})
expectOk(t, err)

status, err := obs.Status()
expectOk(t, err)
bs := status.(*nats.ObjectBucketStatus)
info := bs.StreamInfo()
if info.Config.MaxBytes != 1024 {
t.Fatalf("invalid object stream MaxSize %+v", info.Config.MaxBytes)
}
}

0 comments on commit c75dfd5

Please sign in to comment.