github.com/benchkram/bob@v0.0.0-20240314204020-b7a57f2f9be9/pkg/store/store.go (about)

     1  package store
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"io"
     7  )
     8  
     9  // get inspiration from https://github.com/tus/tusd/blob/48ffebec56fcf3221461b3f8cbe000e5367e2d48/pkg/handler/datastore.go#L50
    10  
    11  type Artifact interface {
    12  	io.ReadWriteCloser
    13  }
    14  
    15  type Store interface {
    16  	NewArtifact(_ context.Context, artifactID string, size int64) (io.WriteCloser, error)
    17  	GetArtifact(_ context.Context, id string) (io.ReadCloser, int64, error)
    18  
    19  	List(context.Context) ([]string, error)
    20  
    21  	Clean(context.Context) error
    22  
    23  	ArtifactExists(ctx context.Context, id string) bool
    24  
    25  	ArtifactRemove(ctx context.Context, id string) error
    26  
    27  	Done() error
    28  }
    29  
    30  var (
    31  	ErrArtifactNotFoundinSrc = fmt.Errorf("artifact not found in src")
    32  	ErrArtifactAlreadyExists = fmt.Errorf("artifact already exists")
    33  )