Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a MaxBytes configuration option to the Object Store #955

Merged
merged 1 commit into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}
}