Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

1.0 KB
Raw Blame
package dispatcher

import (
	"context"

	"github.com/seaweedfs/seaweedfs/weed/filer"
	"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)

// FilerStore is the small subset of filer-client operations the
// daily-replay cursor persister needs (dailyrun.FilerCursorPersister).
// Tests inject an in-memory fake.
type FilerStore interface {
	Read(ctx context.Context, dir, name string) ([]byte, error)
	Save(ctx context.Context, dir, name string, content []byte) error
}

// NewFilerStoreClient adapts a SeaweedFilerClient into a FilerStore.
func NewFilerStoreClient(client filer_pb.SeaweedFilerClient) FilerStore {
	return &filerStoreClient{client: client}
}

type filerStoreClient struct {
	client filer_pb.SeaweedFilerClient
}

func (s *filerStoreClient) Read(ctx context.Context, dir, name string) ([]byte, error) {
	return filer.ReadInsideFiler(ctx, s.client, dir, name)
}

func (s *filerStoreClient) Save(ctx context.Context, dir, name string, content []byte) error {
	return filer.SaveInsideFiler(ctx, s.client, dir, name, content)
}